Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Tsunamijaan/6aaf42fcc0ac9987ddbd454cee949864 to your computer and use it in GitHub Desktop.

Select an option

Save Tsunamijaan/6aaf42fcc0ac9987ddbd454cee949864 to your computer and use it in GitHub Desktop.
To Email User login support besides username
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