• Resolved doyenwilliams

    (@doyenwilliams)


    Currently my registration for is defaulting the nickname to the username rather than the full name (First and Last name).

    However, my preference is that the default nickname is the full name rather than username. How do I set this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support sanjuacharya77

    (@sanjuacharya77)

    Hi @doyenwilliams,

    Please paste this code in your active theme’s functions.php file at the end to set the user nickname to full name instead of a username.

    Here is the code:

    add_action( 'user_registration_after_register_user_action', 'ur_insert_nickname', 1, 3 );
    function ur_insert_nickname( $valid_form_data, $form_id, $user_id ) {
    	$user_nickname = $valid_form_data['first_name']->value . ' ' . $valid_form_data['last_name']->value;
    	update_user_meta( $user_id, 'nickname', $user_nickname );
    }

    Let me know if it works or not and I will get back to you.
    Regards!

    Thread Starter doyenwilliams

    (@doyenwilliams)

    Hi @sanjuacharya77,

    Sorry for taking so long to get back to you on this – but this is NOT resolved.

    Of note, I pasted this code into a custom plugin so that I would not need to change it every time the theme is updated. Please advise if that would change the efficacy of the code provided.

    Either way – people are still ending up with their “Display Name Publicy As…” being their username.

    I’ve since updated everywhere you used “nickname” with “display_name” and am testing same.

    Thread Starter doyenwilliams

    (@doyenwilliams)

    hello again @sanjuacharya77 – confirming that the update DOES NOT work.

    Hi @doyenwilliams,

    You wanted to set the user’s full name as their nickname and the code that we have provided does the same. It has been tested and then provided to you.

    Also, I would recommend not changing any codes of the plugin since it could create issues with the plugin’s functionality.

    Lastly, the codes that we provided need to be pasted in the active theme’s functions.php file. You cannot paste it in the other plugin since there are secondary factors like a priority and overwriting the code that could cause issues. And to prevent it from wiping out because of theme updates, you can create a child theme and then use the code there.

    Let me know if that works after making these changes or not.
    Regards!

    Thread Starter doyenwilliams

    (@doyenwilliams)

    You are correct @sharmadpk03 – I will mark this as resolved and start a new ticket with this query.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Set user nickname to full name instead of username’ is closed to new replies.