Support

Account

Home Forums Front-end Issues acf_form on user profile

Solved

acf_form on user profile

  • Hi,

    I am using Advance Custom Fields to create a new fields within the members profiles. Using the locations panel within the setting, i can target the user group and the fields i want to display (which works perfectly).

    However, i am now using the acf_form function that allows me insert the form into a front end. I have created three test accounts, not including my admin account. Within the admin account, i upload an image and fill out one of the custom fields. When i log into the other account, those fields have already got that values i associated from the admin account.

    This only happen in the front end form as when i visit the wordpress official user profile, its empty (like it should be).

    <?php $options = array(
        'post_id' => $post->ID,
        'field_groups' => array(77),
        'form' => true, 
        'return' => add_query_arg( 'updated', 'true', get_permalink() ),
        'html_before_fields' => '',
        'html_after_fields' => '',
        'submit_value' => 'Update'
    );
    acf_form( $options );
    ?>

    Is there any reason why it is doing that?

    Thanks in advance for the help.

  • Fixed it myself. For future purposes, here is the fix:

    	<?php $options = array(
    	    'post_id' => 'user_'.$current_user->ID,
    	    'field_groups' => array(77),
    	    'form' => true, 
    	    'return' => add_query_arg( 'updated', 'true', get_permalink() ), 
    	    'html_before_fields' => '',
    	    'html_after_fields' => '',
    	    'submit_value' => 'Update' 
    	);
    	acf_form( $options );
    	?>

    Declared the post_id as current user ID taken directly from wordpress

  • Hello!
    Why when user updates some acf variables through front-end form I don’t see any changes in his standard WordPress profile page? Is there any way to sync data between front-end form and profile page? Thanks

    UPD
    Sorry, I did something wrong, everything works like a charm!

  • This reply has been marked as private.
  • Dear @ahmed-abdelaziz please can you help me I have the same proble as @ruslancc
    my acf_form doesn’t updated after I clicked submit button

    this is my code :

    $options = array(
    ‘post_id’ => ‘user_’.$current_user->ID,
    // ‘Username’ =>’user_’.$current_user->user_login,
    // ‘user_email’ =>’user_’.$current_user->email,
    ‘field_groups’ => array(38),
    ‘form’ => true,
    ‘return’ => add_query_arg( ‘updated’, ‘true’, get_permalink() ),
    ‘html_before_fields’ => ”,
    ‘html_after_fields’ => ”,
    ‘submit_value’ => ‘update’
    );
    acf_form( $options );

  • This is my solution that saves the value.

    add_action( 'woocommerce_edit_account_form', 'add_favorite_color_to_edit_account_form' );
    function add_favorite_color_to_edit_account_form() {
        acf_form_head();
    
        $current_user = wp_get_current_user();
    	$options = array(
    		    'post_id' => 'user_'.$current_user->ID,
    		    'field_groups' => array(111),
    		    'form' => true, 
    		    'return' => add_query_arg( 'updated', 'true', get_permalink() ), 
    		    'html_before_fields' => '',
    		    'html_after_fields' => '',
    		    'submit_value' => 'Update' 
    		);
    		acf_form( $options );
    }
Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘acf_form on user profile’ is closed to new replies.