简体   繁体   中英

Wordpress Login not working with email address

on my wordpress site when i clicked on "My Account" link at that time it will me display login page . Currently it's fine .

my problem is when i login with my email address at that time it display me error check below screen shot .

在此处输入图片说明

it just working with the username not in email address and also it says "username and email" .

How can i fix this issue please help me anyone ...

Many thanks

  1. Are you able to login using:

    http://wwww.yourwebsite.com/wp-login.php

Yes? This is probably a theme setting. Check your theme settings for changing the login method by e-mail.

No? - Check your wp_users table in your database and make sure your e-mail adress is correct.

If you don't want to use a plugin, you can add the following to your functions.php file it will allow you to login with the username or email address:

// remove the default filter
remove_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 );
// add custom filter
add_filter( 'authenticate', 'fb_authenticate_username_password', 20, 3 );
function fb_authenticate_username_password( $user, $username, $password ) {

// If an email address is entered in the username box, 
// then look up the matching username and authenticate as per normal, using that.
if ( ! empty( $username ) )
    $user = get_user_by( 'email', $username );

if ( isset( $user->user_login, $user ) )
    $username = $user->user_login;

// using the username found when looking up via email
return wp_authenticate_username_password( NULL, $username, $password );
}

(The above was found here and I tested it and worked for me)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM