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;

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.

1 Answer 1


It's not at all about wp_signon , it's does not do redirect

It seems that (my_front_end_login_fail) function do .

You can simply make sure of this, by commenting this line :

// add_action('wp_login_failed', 'my_front_end_login_fail'); 
  • Thanks so much. Knowing wp_signon didn't redirect, gave me a clue to look further... Plugins, hijacking the process!
    – strattonn
    Commented Jan 7, 2022 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.