How To Force a Pretty Display Name in WordPress
erics, September 4th, 2012
Add the following to your theme’s functions.php file:
1 2 3 4 5 6 7 8 9 |
function force_displayname($user_login, $user) { $result = trim(get_user_meta($user->ID, 'first_name', true) . " " . get_user_meta($user->ID, 'last_name', true)); $result = ucwords($result); if (!empty($result) && ($user->data->display_name!==$result)) { wp_update_user( array ('ID' => $user->ID, 'display_name' => $result)); } } add_action('wp_login','force_displayname',10,2); |