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;
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!
© 2023 Advanced Custom Fields.