Reputation: 307
How or where I must edit wordpress to make user autentication with email and not with username (as it is default)
Upvotes: 2
Views: 797
Reputation: 12469
This should work, add this to the functions.php file:
// 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)
EDIT: This plugin works as well if you don't want to modify the functions file.
Upvotes: 2