Created
July 26, 2021 01:59
-
-
Save wplit/1da9f7a1a497459f6d5b55ff4d7f2661 to your computer and use it in GitHub Desktop.
Prevent redirect if WP login form failed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prevent redirect if login form failed | |
add_action( 'wp_login_failed', 'my_front_end_login_fail' ); | |
function my_front_end_login_fail( $username ) { | |
$referrer = $_SERVER['HTTP_REFERER']; | |
if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) { | |
wp_redirect( $referrer . '?login=failed' ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment