I need to display the user's nickname by default after they are created in the DB, NOT the username.

I am creating a user with:

    wp_create_user( $user_name, $random_password, $user_email );

updating the user nickname field directly after user creation:

    update_user_meta($user_id, 'nickname', $user_nickName);

Now i need the "Display name publicly as" to be set to the nickname as default not the username.

My WP is automatically defaulting the users display name as the username. How do i put the selected value for the display name(Display name publicly as) as my nickname value programmatically?

1 Answer 1


Instead of wp_create_user, use wp_insert_user. So you will be able to set extra variables like nickname, display_name separately than the default value.

For your case, you can code like this:

$args = array (
    'user_login'     => $user_name,
    'user_pass'      => $random_password, //send as plain text password string
    'user_email'     => $user_email,
    'nickname'       => $user_nickName,
    'display_name'   => $user_nickName

wp_insert_user( $args); //on success, it will return user id

Here is the codex refernece for wp_insert_user


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.