Support Forum

Display users nickname and not displayname

GO Gomlers
Gomlers
Member

Since I’m converting from phpbb, all my users are imported to wordpress, and their usernames – as they know them – has been made as wordpress nicknames.

Is there any way I can change this in either the functions-file or in the forum-settings, so that the users displayname is replaced by WP-nickname?

 

I need this to be WP Nickname

5 Answers

New Answer

MP Mr Papa
Mr Papa
Member

No, afraid not – at least without hacking core code…

why not just make the display name be the nickname??  this is the firs time anyone has requested such a thing…  also, users are not required to have a nickname so it could get dicey and problematic.  initially its the same as the display name…

I can make a note of this and consider adding that into the display options in the future…

GO Gomlers
Gomlers
Member

You guys are so quick to respond :) I like that!

I heard you were on vacation Mr Papa, hope you had a nice trip! :)

I understand that this is a special request, and I’m sure I will work it our somehow.. But what did you mean by

why not just make the display name be the nickname??

I can do it and easiest way possible, so if you have anymore to say about how I can do that – please let me know.

MP Mr Papa
Mr Papa
Member

well, I guess your import script is already done, right?  so you would need to right another short php script and run it once…

something like this:

global $wpdb;
$users = $wpdb->get_col("SELECT ID FROM $wpdb->users");
foreach ($users as $user) {
    $nickname = get_user_meta($user, 'nickname', $single);
    $wpdb->query("UPDATE $wpdb->users SET display_name='$nickname' WHERE ID=$user");
}

though I have not actually tested it…  but it grabs all the user ids, fetchs the nickname for each user and sets the display name to the nickname for each user id…

GO Gomlers
Gomlers
Member

Thank you.

I tested your code on a testinstall, and it didn’t work as expected.

All of the users got another option in the drop-down-list in WP-admin:

Normally, it says the username and display name in that field. And now, also “Array” :)

But thank you for your effort! :)

MP Mr Papa
Mr Papa
Member

ah, said I hadnt tested it… ;)

change

    $nickname = get_user_meta($user, ‘nickname’, $single);

to

    $nickname = get_user_meta($user, ‘nickname’, true);