change default display-name (24 posts)

  1. mattiassercu
    Posted 5 years ago #

    in version 3.0.1, the default display-name of new users is the login-name.
    I'm searching for a solution to display by default their firstname and lastname.
    I tried already some suggestions from other forums but nothing worked for me.

    anybody a suggestion?

  2. mirko.menegazzo
    Posted 5 years ago #

    Well...I was about to ask the same thing...I would like to have the full name both for posts and comments.

    Which files are we supposed to modify?

    Thank you

  3. katemgilbert
    Posted 5 years ago #

    I am also searching for a solution to this. It seems there are a couple open threads but no viable answers.

    I tried re-ordering the drop-down list in /wp-admin/user-edit.php as suggested in another thread, but it didn't work...

  4. Tevya
    Posted 5 years ago #

    I would like to do this as well. There is this thread (closed): http://wordpress.org/support/topic/change-newly-registered-users-display-name-publically-as-default?replies=7 that has what seems to be a good fix, but may need to be updated if the latest version of WP changed any of the files you have to alter to implement the fix. I'd really really like to see a plugin that does this so you don't have to modify WP itself and risk loosing the functionality in an update to the core.

    Seems I'm not the only one by looking at this thread, that one, and all the ones linked to in that one.

    I'll pledge a $15 donation to the dev that puts together a plugin. If a few people join me, I'm sure it would be worth somebody's time.

  5. GeoffCrow
    Posted 5 years ago #

    I am also lookig for the same solution. I want the new users display name set to their first plus last name and not the username. Also, I don't want user's the ability to change this.

    It would be wonderful if somebody can do this.

  6. Tevya
    Posted 5 years ago #

    @GeoffCrow I agree, an option to disable it from the user profile would be nice too.

    Based on all the other threads over the past couple years, thought a lot more people would post showing support for this and that we could get 5-10 people pledging $10-$20 to make it happen. Maybe free is the only currency around here?

    If so, is there something else we could do to make this happen?

  7. GeoffCrow
    Posted 5 years ago #

    I am willing to pay but I guess there not that much interest in such a functionality.

    In the mean time I have included this as Rule for my users to register their First and Last name as their username. They can add numbers or dash only.

  8. Carl
    Posted 5 years ago #

    I'm also interested in being able to force new users publicly displayed name into being "Firstname Lastname".

  9. esmi
    Forum Moderator
    Posted 5 years ago #

    This is not the place to discuss paid work.

  10. mirko.menegazzo
    Posted 5 years ago #

    Well, if someone makes a plug in for it and who is using the plug in is willing to make a donation, there is nothing wrong....

  11. esmi
    Forum Moderator
    Posted 5 years ago #

    If you want to make a donation for specific work, please contact the plugin developer privately. This is not the place to discuss it.

  12. joseffb
    Posted 5 years ago #

    I have this in my header file. Simply checks if that current user's display name is set to teh way I want it and if not changes it:

    $showName = $current_user->first_name . " " . $current_user->last_name;
    echo "s: " . $showname . " d: " . $current_user->display_name;
    if ($current_user->display_name != $showName) {
    update_user_meta($current_user->ID, 'display_name', $showName);

    I have it in a member section, so you may want to validate that the user is logged in first.

  13. Carl
    Posted 5 years ago #

    Great work joseffb!

    But don't forget that if you run this code in functions.php or within a plugin you'll probably have to fetch the current_user as an object first.

    Also, since the select in the profile form will break by forcing the setting it might be a good idea to hide that option entirely.

    Revised example (place the following in functions.php or in a plugin):

    //force display-name of users to Firstname Lastname
    function force_pretty_displaynames() {
    	if (is_admin()) {
    	   $current_user = wp_get_current_user();
    	   if ($current_user->display_name != $current_user->first_name." ".$current_user->last_name) update_user_meta($current_user->ID, 'display_name', $current_user->first_name." ".$current_user->last_name);
    	   echo '<style type="text/css">form#your-profile label[for="display_name"], form#your-profile select#display_name   { display:none;}</style>';

    If anyone got a better solution for filtering the profile-form rather than hiding stuff with CSS please contribute!

  14. Tevya
    Posted 5 years ago #

    @carlthome Help me understand this (I'm not a programmer, but can sorta read code).

    Will this work with all existing users? Or will it only force new users to this setting? Also, when you say it will break the profile form if it is forced, does that mean if the user selects something else for their display name?

    As for hiding the option with CSS, that's not too difficult with the plugin Adminimize, you can see how I did it here: http://awesomescreenshot.com/015aofbc8

  15. Tevya
    Posted 5 years ago #

    Does anyone else find it super annoying that topics on this forum get closed after a time, and also that there is no way to directly message another user?

    I found this thread, that seems to have a solution (again I'm not a programmer, so I don't completely understand it all).

    But its closed, so there's no way to ask further questions. And since there's no way to directly message users, I can't ask the authors of those posts. So my question to all of you is: can their solution be put into a plugin or something? So we're not modifying the WP files.

    Also, with a plugin like Register Plus Redux, you can force users to put in First and Last names at registration (though the last post has a solution if you don't want to do that).

  16. Carl
    Posted 5 years ago #

    It will work for all existing users provided they log in at least once. Same goes for new users: change goes in effect upon log in.

    The profile form will work as before apart from the "Display Name"-setting. The reason being that when a user attempts to select a different Display Name, upon sending the form it will revert to the forced setting.

    I've already included a CSS-hiding solution in my example so there should be no worries.

    However, I'd much prefer a proper removal of the drop-list from the form rather than hiding it with CSS. Any suggestions?

  17. Tevya
    Posted 5 years ago #

    Okay, cool. I'll use your solution for now. Did you look at that other thread I linked to? And what do you think? Is that something we could put into a plugin for a more permanent solution that wouldn't require hiding the option?

  18. anup
    Posted 5 years ago #

    @carlthome Excellent solution. works fine with WP 3.1

  19. cruxwireweb
    Posted 5 years ago #

    I'm looking for this, too - a way to change the default display name to firstname lastname.

    The code above that does it when a user logs in for me, because this is for a large membership organization and there is no guarantee a user will log in. In the meantime, I have the membership list display page sort the users by display_name. So, if someone doesn't log in, their listing is listed in the wrong place.

    Sooooo... still hoping for the solution. I'll not mention, because it is inappropriate, that I would make a donation too.

  20. nadula
    Posted 5 years ago #

    Following is the updated version of the plugin wrote by vtxyzzy

    Create a folder like this: wp-content/plugins/substitute_displayname
    Create a new file in that folder called substitute_displayname.php
    Paste the code below into that file.
    Activate the plugin.

    Plugin Name: Substitute Displayname
    Version: 0.1
    Description: Substitutes a default Display name for new registrants.
    Author: Mac McDonald
    /* Version check */
    global $wp_version;
    $exit_msg='Substitute Author requires WordPress 2.5 or newer.  <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>';
    if (version_compare($wp_version,"2.5","<")) {
       exit ($exit_msg);
    function sd_new_login_filter ($login) {
    /* Don't do anything to login, just see if already in database.*/
       global $wpdb, $sd_is_new_login;
       $id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$login'");
       $sd_is_new_login = (isset($id)) ? false : true;
       return $login;
    function sd_substitute_displayname_filter ($display_name) {
       global $sd_is_new_login;
       if ($sd_is_new_login) $display_name = $_POST['first_name']." ".$_POST['last_name'];
       return $display_name;
    add_filter('pre_user_login', 'sd_new_login_filter');
    add_filter('pre_user_display_name', 'sd_substitute_displayname_filter');

    This is THE BEST method I found on the net so far to manipulate display name without altering wp core files (all the changes made to wp core files will be lost after a wp update).

    My member directory page is sorting on display name. So now I can peacefully use that code, knowing it will always sort on surname.

    I can not thank the original plugin coder (vtxyzzy) for his effort on this, as that thread is now locked. But his work helped me a lot.

    Hope this helps u guys too.

  21. marketmo
    Posted 5 years ago #

    So glad to see this, but it doesn't work for us.

    Is this working for others?

    If not, are you also using CIMY user extra fields (we have 2.0.4)?

    If you're using CIMY, have you made the WP FN/LN fields visible in your reg form?

    (I have a suspicion that may be where the conflict lies)

    Running WP 3.1.1

  22. emberstudio
    Posted 4 years ago #

    @nadula - I've been searching around for a solution to this for a while now, and this works perfectly. I'm using a plugin for event registrations and your plugin even changes the displayname to First Name Last Name in the confirmation emails that admins get when a new user account is created and a new event is booked.

    Thank you so much!

  23. razer0r
    Posted 4 years ago #


    after looking an going trough the code I found the solution.

    using version 3.2.1

    in the file wp-includes/user.php edit the folowing
    Move this right under the $last_name and $first_name declaration

    if ( empty($display_name) )
    		$display_name = $user_login;
    	$display_name = apply_filters('pre_user_display_name', $display_name);


    $display_name = $user_login;


    $display_name = $first_name . ' ' . $last_name;

    This will change the default insert at registration and works also with social connect registration forms.

    Hope I could help

  24. Usayd
    Posted 4 years ago #

    Just thought I should mention, the plugin by Mac McDonald seems to have a side-effect of altering existing posts authors.

    The above solution should work, assuming that the user.php file isn't changed in a WordPress update.

Topic Closed

This topic has been closed to new replies.

About this Topic