I would like to update user’s display_name and first_name.
I am doing it this way:
$current_user = wp_get_current_user(); $update = array( 'ID' => $current_user->ID, 'first_name' => $field_value, 'display_name' => $new_display ); wp_update_user( $update ); $current_user = wp_get_current_user(); echo $current_user->user_firstname . ' ' . $current_user->display_name; exit(); // all these are in AJAX request
The ‘echo’ line shows, that first_name is updated, but display_name – not. In the database (wp_users) both fields are updated. The display_name is echo’ed correctly after reload of the page.
Why does $current_user->display_name contain old value after wp_update_user() and wp_get_current_user() invocations, while $current_user->user_firstname contains the new one?
I would appreciate the answer.
- The topic ‘Current user display_name does not update’ is closed to new replies.