Created
December 21, 2014 19:32
-
-
Save bappi-d-great/1c2dd9da452891254b59 to your computer and use it in GitHub Desktop.
Force to have same display name as username in wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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