• Resolved stianand

    (@stianand)


    How can I set the display name t the customers actual name, instead of it’s username.
    I would like it to say:
    Hi John Doe (not Jhon Doe? Log out)
    instead of:
    Hi JohnDoe-99 (not JohnDoe-99? Log out)

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    You can use the code below to show full name instead of username. Here is the article I got the snippet code from. I would recommend using a plugin like?Code Snippets?to add the code to your site: https://www.ads-software.com/plugins/code-snippets/

    add_action ('admin_head','make_display_name_f_name_last_name');
    function make_display_name_f_name_last_name(){
    
    $users = get_users(array('fields'=>'all'));
    
    foreach($users as $user){
        $user = get_userdata($user->ID);    
    
        $display_name = $user->first_name . " " . $user->last_name;
    
        if($display_name!=' ') wp_update_user( array ('ID' => $user->ID, 'display_name' => $display_name) );
            else wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );
    
        if($user->display_name == '')
            wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );
    }
    }

    Hi @stianand

    We’ve not heard back from you in a while, so I’m marking this thread as resolved. If you have further questions, please feel free to open a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Set display name to full name’ is closed to new replies.