• Resolved swhitso2

    (@swhitso2)


    I’ve tried using the code snippet from: https://docs.wpuserregistration.com/docs/custom-code-snippets/ to set the username as the full email address, but it does not work. It always sets it to the string before the @domain. I’ve even tried modifying the snippet so that it simply removes all @ symbols from the email string and sets that as the username, but it doesn’t work either.

    Also the auto login does not work when you have this snippet set. Has there been a fix yet?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Sandip Pokhrel

    (@sandippokharel)

    Hi there,

    Thanks for writing in,

    We just rechecked the code snippet after reading this ticket and we found that the code works as intended. Please check the screenshot in the link below for reference.
    https://prnt.sc/_h5aXDCE8yYl
    Would you please try clearing the site’s cache after adding the code?
    It does have an issue with the auto-login though. I have forwarded this information to our developers. They will look into this.

    Regards!

    Plugin Support Sandip Pokhrel

    (@sandippokharel)

    Hi there,

    Please use the following code.

    add_filter( 'user_registration_before_insert_user', 'ur_insert_username', 10, 3 );
    function ur_insert_username( $user_data, $valid_form_data, $form_id ) {
        $user_data['user_login'] = $valid_form_data['user_email']->value;
        return $user_data;
    }
    
    add_filter( 'user_registration_before_register_user_filter', 'ur_set_email_as_username', 10, 2 );
    function ur_set_email_as_username( $valid_form_data, $form_id ) {
        $valid_form_data['user_login'] = $valid_form_data['user_email'];
        return $valid_form_data;
    }

    Regards!

    Plugin Support Sandip Pokhrel

    (@sandippokharel)

    Hi there,

    Since we haven’t heard from you in a while, I’m going to go ahead and conclude this thread for now. However, if you have any further questions or if there’s anything else we can assist you with, please feel free to continue the conversation.

    Regards!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Username as Email Code Snippet Not Working’ is closed to new replies.