I have a custom sign up process with an ajax login if the user needs to log in (stays on the same page). I have this code in functions.php and call it with Ajax. If credentials are correct, everything is good. If the user or pass is missing all is good but if the credentials are invalid, WP seems to be doing a redirect after wp_signon, is_wp_error is never reached and an error is returned to the site. Is this normal? I've seen a number of examples like this but my code never reaches the is_wp_error check.
$user_signon = wp_signon($creds, false); //$creds = array of login info
if (is_wp_error($user_signon)) {
return rest_ensure_response($user_signon);
} else {
$response->logged_in = true;
wp_set_current_user($user_signon->Id);
}
I've seen code that references
add_action('wp_login_failed', 'my_front_end_login_fail'); // hook failed login
But this looks like a handler for the error and I can't get it to return my code to the is_wp_error line.