How can i allow users to login to my wordpress site using both email id and username? Currently it is allowing only username.


1 Answer 1


As of WordPress 4.5, logging in with the email address instead of username has been added to core functionality. It was introduced in ticket 9568.

If you are running a version of WordPress older than 4.5, the following small small plugin will work. If you don't (or can't) use a plugin, this should - in theory - as well work from within your functions.php file. Just leave the plugin comment header out.

/** Plugin Name: (#90328) Login with E-Mail address */
function login_with_email_address( &$username ) {
    $user = get_user_by( 'email', $username );
    if ( !empty( $user->user_login ) )
        $username = $user->user_login;
    return $username;
add_action( 'wp_authenticate','login_with_email_address' );

Hope this helps.

  • 1
    I edited your question as this is plugin territory and shouldn't be part of a theme. I left your statement in, but offered it as plugin as well.
    – kaiser
    Mar 11, 2013 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.