I recently had to add a group of new users to a WordPress based website and it was frustrating that you have to individually change each user’s display name or else it defaults to their username.
Below is simple block of code that you can copy and paste into your functions.php file which will default the display name to “Firstname Lastname.”
|
1 2 3 4 5 6 7 8 9 |
function change_display_name( $user_id ) { $info = get_userdata( $user_id ); $args = array( 'ID' => $user_id, 'display_name' => $info->first_name . ' ' . $info->last_name ); wp_update_user( $args ); } add_action('user_register','change_display_name'); |


Thanks for the bit of code, I looked everywhere for this.