• Hi

    I’ve setup a WordPress site and I have come across a very strange problem. I have set up a login page for subscribers and if the login is unsuccessful I want the page to redirect back to my custom login page and not the wp-login.php page. To work around this I have added the following code to wp-login.php.

    //	if ( $shake_error_codes && $wp_error->get_error_code() && //in_array( $wp_error->get_error_code(), $shake_error_codes ) )
    //		add_action( 'login_head', 'wp_shake_js', 12 );
    
    //I have replaced the code on line 55 with the following
      if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ){
    header("Location: index.php/login?login_error=1"); exit;
       }

    The redirect is not working at all, I have also used the wp_redirect()
    function instead of header() and it still does not redirect.

    It’s not only the wp-login page that gives this problem, I have also tested the redirects on other pages. For example on my home template page home.php I added the following code right at the top of the page for the sake of testing.

    $location = 'http://www.google.com';
     wp_redirect($location);

    And also

    $location = 'http://www.google.com';
    header("Location: $location");

    I cannot see why any of the redirects would not be working

  • The topic ‘Redirects not working’ is closed to new replies.