Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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