Skip to content

Instantly share code, notes, and snippets.

@dipakcg
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dipakcg/bc041abe05ee49d9d39b to your computer and use it in GitHub Desktop.
Save dipakcg/bc041abe05ee49d9d39b to your computer and use it in GitHub Desktop.
WordPress - Redirect failed login attempts to any location
/* 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