Created
July 31, 2011 19:31
-
-
Save danielbachhuber/1117115 to your computer and use it in GitHub Desktop.
Set WordPress user display name
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 | |
require_once('./wp-load.php'); | |
$all_users = get_users(); | |
foreach( $all_users as $user ) { | |
if ( $user->user_login == $user->display_name ) { | |
$user_info = get_userdata( $user->ID ); | |
$new_display_name = $user_info->first_name . ' ' . $user_info->last_name; | |
$args = array( | |
'ID' => $user->ID, | |
'display_name' => $new_display_name, | |
); | |
wp_update_user( $args ); | |
echo "Set $user->user_login as $new_display_name\n"; | |
} else { | |
echo "$user->display_name already has a byline\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment