Forum Replies Created

Viewing 1 replies (of 1 total)
  • The answer for redirect a user that fails log in is here: https://www.wpinsite.com/code-snippets/how-to-redirect-wordpress-failed-logins/

    Add this to your functions.php:

    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;
       }
    }

    and it works like a charm. This code redirects to the same page as the user tries to log in from. Change $referrer for another page.

Viewing 1 replies (of 1 total)