Support

Account

Home Forums Front-end Issues acf/update_value filter issues Reply To: acf/update_value filter issues

  • Ha! I found the issue with the code and then found the issue with the rest…

    First: my switch statement was
    switch ($field)
    when it should be
    switch ($field['name'])

    After fixing that, I figured out the call wasn’t actually happening on page.php OR within the if statement! Not sure why though.

    In any case, my final code, within the functions.php file is:

    add_filter('acf/update_value', 'nwr_acf_update_profile', 10, 3);
    
    function nwr_acf_update_profile($value, $post_id, $field) {
    	if (bbp_is_single_user_edit()):
    		$current_user = wp_get_current_user();
    		if (current_user_can('edit_user', $current_user->ID)):
    			$userdata = array('ID' => $current_user->ID);
    			switch ($field['name']):
    				case 'user_first_name':
    					if ($value != $current_user->first_name):
    						$userdata['first_name'] = $value;
    					endif;
    					break;
    			endswitch;
    			if (count($userdata) > 1):
    				wp_update_user($userdata);
    			endif;
    		endif;
    	endif;
    	return $value;
    }