Make WordPress User Name the Email Address

Is it possible to make WordPress user name the Email Address?

So unername could be hidden or not required and is replaced with email address.

Read More

I know there are plugins that can allow users to use their email as the log in, but they still have to enter the username when they register. I want to try and do away with the username.

Related posts

Leave a Reply

3 comments

  1. I know this thread is over a year old now, but I just tested creating an account where the username is an email address and it works. In theory, you could create a front-end signup form that saves the email variable to both the username and email fields in the database.

    WordPress allows usernames with some special characters, so this is a completely valid way to sign people up: http://codex.wordpress.org/Function_Reference/sanitize_user

  2. Yes it is possible. Even you can configure WordPress to Login, Register and Retrieve Password using Email only.

    You can put the code below in your theme’s functions.php file.

    Step-1: Remove Username textfield

    add_action('login_head', function(){
    ?>
        <style>
            #registerform > p:first-child{
                display:none;
            }
        </style>
    
        <script type="text/javascript" src="<?php echo site_url('/wp-includes/js/jquery/jquery.js'); ?>"></script>
        <script type="text/javascript">
            jQuery(document).ready(function($){
                $('#registerform > p:first-child').css('display', 'none');
            });
        </script>
    <?php
    });
    

    Step-2: Remove Username error

    //Remove error for username, only show error for email only.
    add_filter('registration_errors', function($wp_error, $sanitized_user_login, $user_email){
        if(isset($wp_error->errors['empty_username'])){
            unset($wp_error->errors['empty_username']);
        }
    
        if(isset($wp_error->errors['username_exists'])){
            unset($wp_error->errors['username_exists']);
        }
        return $wp_error;
    }, 10, 3);
    

    Step-3: Manipulate Background Registration Functionality.

    add_action('login_form_register', function(){
        if(isset($_POST['user_login']) && isset($_POST['user_email']) && !empty($_POST['user_email'])){
            $_POST['user_login'] = $_POST['user_email'];
        }
    });
    

    There is also a plugin to achieve this functionality.

    Plugin: https://wordpress.org/plugins/smart-wp-login/

  3. The username is a core entity in the WordPress DB and philosophy and it can’t be bypassed like that. Now if you want to let users login with their emails, use this plugin: http://wordpress.org/extend/plugins/wp-email-login/ It allows you to login with either email/pass or username/pass. Found it like a month ago, works like a charm.

    Even plugins that use alternative means for registration and login (facebook, twitter and Google) create a username (for instance, one plugins I’ve tried creates usernames like fbX where X is the facebook ID. Unfortunately it is not something we can work around.

    Hope this helps! 🙂