i’ve added this code to my site-specific plugin, as was suggested a while ago for email login, etc:
// wp-members login redirect to referrer
add_filter( ‘login_url’, ‘my_login_url’ );
function my_login_url( $url ) {
return add_query_arg( ‘redirect_to’, wpmem_current_url(), wpmem_login_url() );
}
// wp-members login with username or email
add_filter( ‘authenticate’, ‘my_login_with_email’, 10, 3 );
function my_login_with_email( $user=null, $username, $password ){
// First, check by username.
$user = get_user_by( ‘login’, $username );
// If the username is invalid, check by email.
if( ! $user )
$user = get_user_by( ’email’, $username );
// Validate the password.
if( $user and wp_check_password( $password, $user->user_pass ) )
// If password checks out, return a valid login.
return $user;
// Return a failed login.
return new WP_Error( ‘login’, “Login Failed” );
}
add_filter( ‘wpmem_inc_login_inputs’, ‘my_login_with_email_form’ );
function my_login_with_email_form( $array ){
$array[0][‘name’] = ‘Email or Username’;
return $array;
}
// wp-members reset passwd with username or email
add_filter( ‘wpmem_inc_resetpassword_inputs’, ‘my_resetpassword_inputs’ );
function my_resetpassword_inputs( $array )
{
$array[0][‘name’] = ‘Email or Username’;
return array_slice($array, 0, 1);
}
add_filter( ‘wpmem_pwdreset_args’, ‘my_pwdreset_args’ );
function my_pwdreset_args( $args )
{
// First, check by username.
$user = get_user_by( ‘login’, $args[‘user’] );
// If the username is invalid, check by email.
if( !$user )
$user = get_user_by( ’email’, $args[‘user’] );
if( $user )
{
$args[‘user’] = $user->user_login;
$args[’email’] = $user->user_email;
}
return $args;
}