Hi. I’m currently using the following PHP code to force UserNames as DisplayNames.
Is it possible to amend this code so that instead users’ Nicenames are used instead?
I’m a total noob to this so apologies if the answer is glaringly obvious!
​
add\_action( ‘user\_register’, ‘set\_login\_as\_displayname’ );
add\_action( ‘profile\_update’, ‘set\_login\_as\_displayname’ );
​
function set\_login\_as\_displayname( $user\_id )
{
$data = get\_userdata( $user\_id );
​
if ($data->user\_login != $data->display\_name) {
wp\_update\_user( array (‘ID’ => $user\_id, ‘display\_name’ => $data->user\_login));
}
}
[ad_2]
Used where? Displayed somewhere on the site? Where? “Nice names” are displayed by default on the frontend.
You need to provide more information. Can you share your URL?