Last active
August 29, 2015 14:20
-
-
Save dipakcg/bc041abe05ee49d9d39b to your computer and use it in GitHub Desktop.
WordPress - Redirect failed login attempts to any location
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
/* Adding this snippet to the functions.php or your wordpress theme will allow you to redirect failed login attempts to any location. */ | |
add_action( 'wp_login_failed', 'dcg_redirect_failed_login' ); | |
function dcg_redirect_failed_login( $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