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

    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,
    Majid