• Resolved pauliverbot

    (@pauliverbot)


    Hello,

    I have a registration form where the user enters the name, surname and e-mail (but no username). UM generates the username by putting together the name and surname in lowercase. Is there a hook to change this behavior so that I can change the username to anything I want (e.g. a random number or random combination of letters) once the registration form is submitted? If this is the case, how can I get the username field from the form?

    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @pauliverbot

    You can use this action hook to change the user login/username:

    add_action("um_registration_complete","um_071621_change_username", 1, 2 );
    function um_071621_change_username( $user_id, $args ){
       $new_login = '123abc';
       wp_update_user( ['ID' => $user_id, 'user_login' => $new_login]  );
    
    }

    Regards,

    Thread Starter pauliverbot

    (@pauliverbot)

    That was the hook I was looking for. thank you for your help, champ.ninja 😉

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @pauliverbot

    Thanks for letting us know. I’m marking this as resolved now.

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘change username after registration submit – hook?’ is closed to new replies.