Skip to content

Instantly share code, notes, and snippets.

@devinsays
Created August 30, 2015 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devinsays/aa0a580242f705e98de5 to your computer and use it in GitHub Desktop.
Save devinsays/aa0a580242f705e98de5 to your computer and use it in GitHub Desktop.
Allow login by e-mail address
<?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