By adding “?login – failed” code unable to access my dashboard

Question

I am using the following snippet code to stop customer redirect after wrong password or empty username and password in my WordPress theme.

But by adding this code i am unable to access my admin dashboard from url like “www.example.com/ignite” or “www.example.com/wp-admin”


add_action( 'wp_login_failed', 'elementor_form_login_fail', 9999999 );
function elementor_form_login_fail( $username ) {
   $referrer = $_SERVER['HTTP_REFERER']; 
  if ((!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') )) {
        wp_redirect(preg_replace('/?.*/', '', $referrer) . '/?login=failed' );
        exit;
   }
}


add_action( 'wp_authenticate', 'elementor_form_login_empty', 1, 2 );
function elementor_form_login_empty( $username, $pwd ) {
    $referrer = $_SERVER['HTTP_REFERER']; 
    
 if ( empty( $username ) || empty( $pwd ) ) {
    
     if ((!strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') )) {
       wp_redirect(preg_replace('/?.*/', '', $referrer) . '/?login=failed' );
      exit;
    }
   exit();
 }
}

0
user1750420 4 months 0 Answers 14 views 0

Leave an answer