1

I'm trying to find a way to prevent the login screen from showing up when user makes a mistake filling out the login form.

So, right now, I have the login form printed on a custom template. But if the users makes a mistake filling it out, it redirects them to the wordpress form to try again. I want to redirect away from that.

This is the code I had but it's not working.

add_action('login_form', 'redirect_invalid_login');

function redirect_invalid_login(){
    global $error;

    if($error)
        header('Location: '.get_bloginfo('url').'/client-login/?message=6');
}

Now login_form is too late I believe because stuff already gets printed to the page. I haven't been able to find a hook that works. Is there a hook for this? Or perhaps a different way to do it?

1 Answer 1

4

The login_init hook is the first one to be called in wp-login.php, so try hooking into it instead.

function redirect_invalid_login()
{
    global $error;

    if( $error )
    {
        wp_redirect( get_bloginfo( 'url' ) . '/client-login/?message=6' );
        die();
    }
}
add_action( 'login_init', 'redirect_invalid_login' );

If that doesn't work, please provide more details.

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.