Select Page
WordPress redirect after failed login FIX
You just created your fancy front end login form and everything looks great clients are going to love not haveing to use the WordPress login screen and your finally feeling like you have a legit feel to you member are then bam you put in the wrong password and it redirects you to the WP login screen what now?

You just created your fancy front end login form and everything looks great clients are going to love not haveing to use the WordPress login screen and your finally feeling like you have a legit feel to you member are then bam you put in the wrong password and it redirects you to the WP login screen what now?

Add the below code to your functions.php file.

 

add_action( 'wp_login_failed', 'my_front_end_login_fail' );  // hook failed login

function my_front_end_login_fail( $username ) {
   $referrer = $_SERVER['HTTP_REFERER'];  // where did the post submission come from?
   // if there's a valid referrer, and it's not the default log-in screen
   if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) {
      wp_redirect( $referrer . '?login=failed' );  // let's append some information (login=failed) to the URL for the theme to use
      exit;
   }
}

 

 

Fixed now it will redirect back to the page that the login form is on.

Preloader