• Hello,

    I’m creating a registration form with Ultimate Member and I’d like the username (login) to be the email address of the person registering.

    Is there a way to do this with Ultimate Member? Do I need to install another plugin? Do I need to add a snippet to do this?

    Can you help?

    Many thanks in advance,
    Alexis Grolot

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

    (@yuriinalivaiko)

    Hello @alexisgrolot

    The plugin automatically makes user login from email if there is no user login, username, first name and last name in the registration form. Otherwise you need a code snippet.

    Try to remove the “Username” (user_login) field from the registration form and add this code snippet to the functions.php file in the active theme directory.

    // make a login from email.
    add_filter( 'um_add_user_frontend_submitted', function( $args, $form_data ) {
    	if ( empty( $args['user_login'] ) && ! empty( $args['user_email'] ) ) {
    		$args['user_login'] = sanitize_user( strtolower( $args['user_email'] ), true );
    	}
    	return $args;
    }, 10, 2 );

    Regards

    Thread Starter Alexis Grolot

    (@alexisgrolot)

    Hello @yuriinalivaiko ,
    Thank you very much for your very detailed reply and for taking the time to read and reply to my message.

    In my registration form, there is a first name field, a last name field and an email field. I did remove the username field. And I’ve added your code snippet via the Code Snippets plugin.

    But when I validate the registration via the registration form, it displays a blank page with a message:

    “There has been a critical error on this site.
    Learn more about WordPress debugging.”

    Can you help me out again and thanks again,
    Alexis Grolot

    Plugin Support yuriinalivaiko

    (@yuriinalivaiko)

    Sorry for the late answer.

    A forum can replace special symbols in the code, so you should not copy and paste it directly. Use a PHP code editor that can verify a code for the syntax errors when you edit PHP files.

    Did you add a code to a proper place? It’s better to add custom PHP code to the end of the functions.php file in the theme directory. Using a child theme is recommended. A code added or edited via a snippets plugin may work wrong.

    Regards

    Plugin Support yuriinalivaiko

    (@yuriinalivaiko)

    Hi @alexisgrolot

    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

    Thread Starter Alexis Grolot

    (@alexisgrolot)

    Hello @yuriinalivaiko ,
    Thank you very much for your very detailed reply and for taking the time to read and reply to my message.

    And sorry for the late reply.

    I tried again by adding the custom PHP code at the end of the functions.php file in the theme directory. But I didn’t use a child theme because it’s not final yet. I use the Divi theme, as well as the Divi Builder.

    Can you help me out again and thanks again,
    Alexis Grolot

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘I’d like the username (login) to be the email address’ is closed to new replies.