Support

Account

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

  • Thanks pal. Sorted it like this:

    function user_register_pre_save( $post_id ) {
        
    
        // check if this is to be a new post
        if( $post_id != 'new' ) {
        	
        	preg_match_all('!\d+!', $post_id, $num_id);
        	$num_id = implode(' ', $num_id[0]); 
        	$num_id = (int)$num_id;
    
        	$xuserdata = array(
    		'ID' 		   => $num_id,
    		'first_name'   => $_POST['acf']['field_567a4d0a839b3'],
    		'last_name'	   => $_POST['acf']['field_567a4d10839b4'],
    		'user_email'	   => $_POST['acf']['field_567a4c416d6c1'],
    		'display_name'  => $_POST['acf']['field_567a4d0a839b3'] . ' ' . $_POST['acf']['field_567a4d10839b4']
    		);
    
        	wp_update_user($xuserdata);
    
      		return $post_id;
        }
     	
    
     	$userdata = array(
    		'ID' 		   => $user_id,
    		'user_login'	   => $_POST['acf']['field_567a4c3c6d6c0'],
    		'user_pass'	   => $_POST['acf']['field_567a4c4c6d6c2'],
    		'user_email'	   => $_POST['acf']['field_567a4c416d6c1'],
    		'first_name'    => $_POST['acf']['field_567a4d0a839b3'],
    		'last_name'	   => $_POST['acf']['field_567a4d10839b4'],
    		'display_name'  => $_POST['acf']['field_567a4d0a839b3'] . ' ' . $_POST['acf']['field_567a4d10839b4'],
    		'role'		   => $_POST['acf']['field_567ac0b49e48b']
    	);
    
    	//register user
    	$user_id = wp_insert_user($userdata);
    	$user_id = 'user_'.$user_id;
    	return $user_id;
    }
    
    add_filter('acf/pre_save_post' , 'user_register_pre_save');