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;
}
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.