WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;

        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

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' );
add_action( 'login_init', 'redirect_invalid_login' );

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

share|improve this answer

Your Answer


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.