I have a form that allows people to update their display_name. However, this doesn’t work. So what I’m doing is the following:
I prefill the form field with the {wp_user_display_name}
Then I use Brickforge’s “update user meta” to update the nickname meta key. This does update it in the backend!
Now I want the nickname to synchronize automatically to the “Display name publicly as” field, but this is where the trouble starts as this field is not auto updating whenever I save the form.
Any ideas on how to fix this or sync the 2 fields? Huge thanks in advance as I’ve been struggling with this for over 5 hours now.
That also didn’t work, I have now figured it out, needed to add this to the functions.php:
$user_id = get_current_user_id(); // get current user ID
$nickname = get_user_meta($user_id, 'nickname', true); // get nickname
if ($user_id && $nickname) {
wp_update_user(array('ID' => $user_id, 'display_name' => $nickname));
}
Ohh this is perfect thank you!
The other code also logged users out after a few reloads for some reason. Would that be the case with this code as well? Or since this is a function it wouldnt have that problem?