I'm creating a simple directory from the user accounts and want to simplify it as much as possible for the users. I changed the label on nickname to Lastname, Firstname so that the users can be alphabetized by the nickname field, but I want the display_name to default, or even force, to the nickname field. I haven't seen a plugin, so I'm looking for something I can add to the functions to do this. Any ideas?


You can force this with a hook that activates when the profile is updated. The next step would be to hide the display_name select box, you can do that with some Javascript.

add_action( 'user_profile_update_errors', 'wpse7352_set_user_display_name_to_nickname', 10, 3 );
function wpse7352_set_user_display_name_to_nickname( &$errors, $update, &$user )
    if ( ! empty( $user->nickname ) ) {
        $user->display_name = $user->nickname;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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