How to set the Default Display Name and Nickname for WordPress Users

Is it possible to provide a default nickname for the user after registration versus the email? After registration would like default to LocalBeacon #id (e.g. LocalBeacon #100, LocalBeacon #101, LocalBeacon #102). Will increase by 1 after each new individual registers.

  • Majid

    Hello Kai
    I hope you are doing great today :slight_smile:

    Using the code provided in the last chat session was able to change any newly registered user nicknames in my site

    Just make sure you have the following code inside your functions.php file or into an mu-plugin, both solutions should work.

    // Change user Nickname
    function set_default_nick_name( $user_id ) {
    	$user = get_userdata( $user_id );
    	$name = 'LocalBeacon #10' . $user_id;
    	$args = array(
    		'ID' => $user_id,
    		'nickname' => $name,
    		'display_name' => $name
    	wp_update_user( $args );
    add_action( 'user_register', 'set_default_nick_name' );

    Best Regards,

  • Ben

    Hello Majid,

    Please can you help me out here?

    I do have a registration form on my wwbsite that has provisions for

    1. Username
    2. First name
    3. Last name
    4. Email and
    5. Password

    What I want to achieve is to auto update the default Nickname* and Display publicly As* fields to use the users first and last name.

    I.e, by default, after registration, instead of taking the username as a default value, I want those fields to be set to the user's Full Name Pending when he or she manually updates it.

  • Oguzhan Selcuk Bulbul

    Hey Ben ,

    Hope you're well.

    First of all, let me tell you one thing if you can contact us through live chat you can get the answer faster, and if we need to be open new thread for your question we can do that for you.

    And for your question, can you try to place this codes to your themes functions.php file?

    // Change user defaults
    function change_user_defaults($user_id) {
    	$user = get_userdata($user_id);
    	$args = array(
    		'ID' => $user_id,
    		'nickname' => "$user->first_name$user->last_name",
    		'display_name' => "$user->first_name $user->last_name"
    	wp_update_user( $args );
    add_action('user_register', 'change_user_defaults');