Force NiceNames as DisplayNames

[ad_1]

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]
1 Comment
  1. 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?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer