Home › Forums › Front-end Issues › Front End update form › Reply To: Front End update form
I’ll share the solution with you.
I just understood that in the acf_form () function; you had to pass all the form tags.
Whose input action
Here is the script that works to adapt of course to your needs:
/*====Shortcode contenu News Tab - ACF ================= */
add_action( 'admin_post_adaptiveweb_save_profile_form', 'adaptiveweb_save_profile_form' );
function adaptiveweb_save_profile_form() {
if(!isset($_REQUEST['user_id'])) return;
do_action('acf/save_post', $_REQUEST['user_id']);
wp_redirect(add_query_arg('updated', 'success', wp_get_referer()));
exit;
}
/* Contenu ACF dans Shortcode */
function contenu_shortcode_onglet( $atts ) {
$user_ID = get_current_user_id();
$user = wp_get_current_user();
$options = array(
// 'field_groups' => ['group_618a52d0b2b74'],
'fields' => [
'field_618a52d0b874e',
'field_618a52d0b878d',
'field_618a52d0b87ce',
'field_618a52d0b880f',
'field_618a52d0b870d',
'field_618a526a02cd7',
'field_618a526a02d0f'
],
'form_attributes' => [
'method' => 'POST',
'action' => admin_url("admin-post.php"),
],
'html_before_fields' => sprintf(
'<input type="hidden" name="action" value="adaptiveweb_save_profile_form">
<input type="hidden" name="user_id" value="user_%s">', $user->ID
),
'post_id' => "user_{$user->ID}",
'form' => true,
'html_submit_button' => '<button type="submit" class="acf-button button" value="Update Profile">Update Profile</button>',
'updated_message' => __('<div class="woocommerce-message" role="alert">
Les détails du compte ont bien été modifiés.</div>', 'acf')
);
acf_form($options);
}
add_shortcode( 'onglet', 'contenu_shortcode_onglet' );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.