Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there a way I can force all users display names to be Firstname Lastname or alternatively change this to be the default?

share|improve this question
add comment

1 Answer

This is set during user registration. You can change the value per filter 'user_register'.

Sample code, not tested:

/* Plugin Name: First name plus last name as default display name. */
add_action( 'user_register', 'wpse_67444_first_last_display_name' );

function wpse_67444_first_last_display_name( $user_id )
{
    $data = get_userdata( $userid );
    // check if these data are available in your real code!
    wp_update_user( 
        array (
            'ID' => $user_id, 
            'display_name' => "$data->first_name $data->last_name"
        ) 
    );
}
share|improve this answer
    
Added to functions.php? Also, is the wpse_67444 part important? –  Svish Oct 7 '12 at 23:05
1  
I would put it into a separate plugin. The prefix is just a convention on our site to avoid collisions with other code. –  toscho Oct 7 '12 at 23:24
    
WordPress newb here, hehe. How would you put it in a separate plugin? Is it just a matter of putting it in a certain file in a certain folder or something?` –  Svish Oct 8 '12 at 17:49
    
@Svish See my edit. Put the code into a separate file and move it to your plugin directory. Then activate it – done. –  toscho Oct 8 '12 at 17:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.