WordPress Quick Tip — Enable Login To The WordPress Admin With Your Email Id

Recently I came across a unique request from one of my clients regarding wp-admin login. Most of the times the people who manage multiple WordPress sites, get confused with the login credentials. Worst case, they forget the User Name of the respective sites. So I tried to find a solution for them and while researching I stumbled across a unique style of WordPress authentication. You can optionally login into your WordPress admin / dashboard by using e-mail id as well. For that, you need to add the following code in functions.php:

function custom_login($username)
{
    $user = get_user_by_email($username);
    if(!empty($user->user_login))
        $username = $user->user_login;
    return $username;
}
add_action('wp_authenticate',' custom_login ');
Posted In:

UX & Frontend Design, Code Snippets

Comment on WordPress Quick Tip — Enable Login To The WordPress Admin With Your Email Id

Your email address will not be published. Required fields are marked *