Skip to content

Instantly share code, notes, and snippets.

@devinsays
Last active January 4, 2016 01:14
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save devinsays/1b03494b5eae702d6e35 to your computer and use it in GitHub Desktop.
Allows visitors to log in using e-mail address
<?php
/**
* Allows visitors to log in using e-mail address
*
* @param string username passed by reference
*/
function prefix_authenticate_by_email( &$username ) {
$user = get_user_by( 'email', $username );
if ( false !== $user ) {
$username = $user->user_login;
}
}
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