Created
August 30, 2015 23:03
-
-
Save devinsays/aa0a580242f705e98de5 to your computer and use it in GitHub Desktop.
Allow login by e-mail address
This file contains 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
<?php | |
/** | |
* Allows customer to log in using e-mail address | |
* | |
* @param string username | |
*/ | |
function prefix_authenticate_by_email( &$username ) { | |
error_log( $username ); | |
$user = get_user_by( 'email', $username ); | |
if ( ! empty( $user ) ) : | |
$username = $user->user_login; | |
endif; | |
return; | |
} | |
add_action( 'wp_authenticate', 'prefix_authenticate_by_email' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment