It’s possible, you must change the filter for the name.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // 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 ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.