Support

Account

Home Forums ACF PRO ACF Form not saving data Reply To: ACF Form not saving data

  • Is this for creating a new user or for adding these fields to a CPT? or are you trying to do both at the same time?

    in your code $args for acf_form 'post_id' => $user_id,
    I did miss this, so your form should be either creating a new user or updating and existing one, that looks right.

    
    if ( is_user_logged_in() == true ) : 
       global $current_user;
       $user_id = 'user_'.$current_user->ID;
       else : $user_id = 'new';
    endif;
    

    The other problem you have that I just noticed is this at the end of your pre_save_post filter

    
    //register user
    $user_id = wp_insert_user($userdata);
    
    	return $post_id;
    

    first thing is that you’re returning $post_id instead of $user_id and the second thing is that you can’t return the bare user ID for ACF to work, this needs to look like this

    
    $user_id = wp_insert_user($userdata);
    $user_id = 'user_'.$user_id;
    return $user_id;