WordPress.org

Ready to get started?Download WordPress

Forums

Change Newly registered users "display name publically as" default? (7 posts)

  1. mhains
    Member
    Posted 5 years ago #

    When new users create accounts, the display name defaults to their username, not their "firstname lastname" as I'd prefer. I don't expect my users will be saavy enough to make the change.

    How do I change the default display name?

    Thanks in advance
    Michael

  2. levifig
    Member
    Posted 5 years ago #

    I'll second this request!!
    I want to make "First Name && Last Name" the default display name...

    Thanks
    ~Levi

  3. levifig
    Member
    Posted 5 years ago #

    And along with us...

    http://wordpress.org/support/topic/148622
    http://wordpress.org/support/topic/151108
    http://wordpress.org/support/topic/199672

    Possible solution for the more tech savvy (still think this should be an admin panel option):
    http://wordpress.org/support/topic/188168

    Good luck

  4. levifig
    Member
    Posted 5 years ago #

    Scratch that "possible solution"... It's not! :|

    Someone please help? :(

  5. levifig
    Member
    Posted 5 years ago #

    Ok, a fix for this:

    1. Change registration.php (/wp-includes).
    BEFORE

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

    AFTER

    if ( empty($display_name) )
    		$display_name = $first_name.' '.$last_name;
    	$display_name = apply_filters('pre_user_display_name', $display_name);

    This change will make the default write to the DB on a user creation be "Firstname Lastname" instead of their login ID. But this isn't enough...

    2. By default, on the profile edit page, the first line of the drop-down menu (and the default therefore) is, again, user login id. So when a user changes something on that page, it will write it back to the display name.
    To solve this, we edit user-edit.php (/wp-admin) and move the line:

    $public_display['display_firstlast'] = $profileuser->first_name.' '.$profileuser->last_name;

    to be the first line, right under:

    $public_display = array();

    BTW, not sure if this last chance is absolutely crucial, but at least this way it shows up correctly on the user edit page. :)

    Hope this helps someone else.
    Have fun guys! :)

  6. talgalili
    Member
    Posted 5 years ago #

    Hi levifig, this did help.

    Other members - where can I suggest this as a core feature, or a plugin idea ?

    Tal

  7. spedney
    Member
    Posted 4 years ago #

    Levifig,
    But, what if the first and last names are empty?
    It could happen that the person who registered the new user didn't enter these values in, so you could add a little check like this:

    if ( empty($display_name) ) {
    		if ( !empty($first_name) && empty($last_name))
    			$display_name = $first_name;
    		if ( !empty($last_name) && empty($first_name))
    			$display_name = $last_name;
    		if ( !empty($first_name) && !empty($last_name))
    			$display_name = $first_name.' '.$last_name;
    		}
    	if ( empty($display_name) )
    		$display_name = $user_login;
    	$display_name = apply_filters('pre_user_display_name', $display_name);
    		}
    	if ( empty($display_name) )
    		$display_name = $user_login;
    	$display_name = apply_filters('pre_user_display_name', $display_name);

Topic Closed

This topic has been closed to new replies.

About this Topic