diff --git a/basic-auth.php b/basic-auth.php index 1ef6f85..a9646a6 100644 --- a/basic-auth.php +++ b/basic-auth.php @@ -34,7 +34,19 @@ function json_basic_auth_handler( $user ) { */ remove_filter( 'determine_current_user', 'json_basic_auth_handler', 20 ); - $user = wp_authenticate( $username, $password ); + $user = get_user_by('login', $username); + + if ( !$user ) { + $user = get_user_by('email', $username); + } + + if ( !$user ) { + return null; + } + + if ( ! wp_check_password( $password, $user->user_pass, $user->ID ) ) { + return null; + } add_filter( 'determine_current_user', 'json_basic_auth_handler', 20 );