Support

Account

Home Forums General Issues ACF_Form wp_update_user not adding name

Unread

ACF_Form wp_update_user not adding name

  • Hi All,

    Any reason this would not be creating first and last name? All of the other user fields are created correctly…including those that use the first_name and last_name as a base?

    function register_user($post_id) {
    
    	
    	if( $post_id == 'abcnew' ) {
    
            $f      = $_POST['acf'];
    
            $first_name = $f['field_5c984b9606d4b'];
            $last_name    = $f['field_5c984b9c6cfd0'];
            $email  = $f['field_5c984ba26cfd1'];
            $user_name = $first_name." ".$last_name;
            $role = $f['field_5c98b15542b39'];
            $role = strtolower($role); 
    
            if ( !username_exists($user_name) && !email_exists($email) ) {
    
                $random_password = wp_generate_password( $length = 8, false );
                $key_active      = wp_generate_password( $length = 20, false );
    
                $user_id         = wp_create_user( $user_name, $random_password, $email );
    
                $user_id_role    = new WP_User($user_id);          
                $user_id_role->set_role($role);
               
               	 //GFCommon::log_debug("First Name...".$first_name);
               	 //GFCommon::log_debug("Last Name...".$last_name);
    
                wp_update_user( array(
                    'ID'            => $user_id,
                    'first_name'    => "First Name",
        			'last_name'     => "Last Name",
                    'user_login'    => $user_name,
                    'nickname' 		=> $first_name . " " . $last_name,
                    'display_name'  => $first_name . " " . $last_name, 
                   
                ));
                 
                do_action('acf/save_post', "user_".$user_id);
    
            }
        } 
    }
Viewing 1 post (of 1 total)

The topic ‘ACF_Form wp_update_user not adding name’ is closed to new replies.