Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bappi-d-great/1c2dd9da452891254b59 to your computer and use it in GitHub Desktop.
Save bappi-d-great/1c2dd9da452891254b59 to your computer and use it in GitHub Desktop.
Force to have same display name as username in wordpress
<?php
add_action('init', 'change_display_name' );
add_action( 'profile_update', 'change_display_name' );
function change_display_name() {
$users = get_users();
foreach( $users as $user ){
if( $user->user_login != $user->display_name ){
wp_update_user( array ('ID' => $user->ID, 'display_name'=> $user->user_login) ) ;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment