• Resolved ogagliardijr

    (@ogagliardijr)


    I have the “Allow Users to Log in With Email” feature turn on. The usernames that are generated are not the email address. For example: If the email address is john.smith@gmail com, the username that is generated is: john-smithgmail-com. Another example: If the email address is: [email protected], the username that is generated is: maryperez93ymail-com.

    Is there any way to have Profile Builder plugin make the username be the same as the email address?

    Thank you

Viewing 1 replies (of 1 total)
  • Hi,

    Thank you for reaching out to us.

    With some custom code we can remove the domain from the user name:

    1. Create an empty plugin like this: https://gist.github.com/sareiodata/76f701e01db6685829db
    2. Add the following code to the end of it:

    /*
     * Filter to change the random username when "Allow Users to Log in With" is set to Email
     * The username will display the email address without the domain
     */
    
    add_filter('wppb_generated_random_username', 'wppbc_rand_username', 10, 2);
    function wppbc_rand_username( $username, $user_email ){
        $username = explode('@', $user_email);
        $username = $username[0];
        $j = 1;
        while ( username_exists( $username ) ){
            $username = $username . '_' . $j;
            $j++;
        }
    
        return $username;
    }

    3. Install this plugin via FTP (copy it inside wp-content/plugins) or create a zip archive with it and install it via the WordPress plugin upload functionality

    The custom code will not modify existing users. It will only work for new registrations.

    After installing and activating the plugin please register a test user and let me know if it works for you.

    Best regards,

Viewing 1 replies (of 1 total)
  • The topic ‘The “Allow Users to Log in With Email” feature generates cryptic username’ is closed to new replies.