• Resolved nikolausii

    (@nikolausii)


    I found this topic:

    https://www.ads-software.com/support/topic/auto-generated-username-ultimatemember/

    But it didn’t work for me. I use the same code, only in my case the meta key is called verein_name. However, the user name is always saved as the standard combination: firstnamelastname
    Has the procedure changed here?

    This is my code in the functions.php:

    add_action("um_registration_complete","um_042121_change_user_role", 1, 2 );
        function um_042121_change_user_role( $user_id, $args ){
            try {
                if( isset( $args['verein_name'] ) ){        
                    wp_update_user( array( 'ID' => $user_id, 'user_login' => $args['verein_name'] ) );
                } else {
                    wp_update_user( array( 'ID' => $user_id, 'user_login' => $args['last_name'].'-'.$args['first_name'] ) );
                }
            }
            catch(Exception $e) {
                echo 'Message: ' .$e->getMessage();
            }
        }

    Am I missing something?
    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support andrewshu

    (@andrewshu)

    Hello @nikolausii

    Try to change priority of hook:

    add_action(“um_registration_complete”,”um_042121_change_user_role”, 1000, 2 );

    Regards.

    Plugin Support andrewshu

    (@andrewshu)

    Hi @nikolausii

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. ??

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Generate username after registraion’ is closed to new replies.