Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Created July 31, 2011 19:31
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielbachhuber/1117115 to your computer and use it in GitHub Desktop.
Save danielbachhuber/1117115 to your computer and use it in GitHub Desktop.
Set WordPress user display name
<?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