Created
January 5, 2019 09:14
-
-
Save Tsunamijaan/6aaf42fcc0ac9987ddbd454cee949864 to your computer and use it in GitHub Desktop.
To Email User login support besides username
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function dr_email_login_authenticate( $user, $username, $password ) { | |
| if ( is_a( $user, 'WP_User' ) ) | |
| return $user; | |
| if ( !empty( $username ) ) { | |
| $username = str_replace( '&', '&', stripslashes( $username ) ); | |
| $user = get_user_by( 'email', $username ); | |
| if ( isset( $user, $user->user_login, $user->user_status ) && 0 == (int) $user->user_status ) | |
| $username = $user->user_login; | |
| } | |
| return wp_authenticate_username_password( null, $username, $password ); | |
| } | |
| remove_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 ); | |
| add_filter( 'authenticate', 'dr_email_login_authenticate', 20, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment