Skip to content

Instantly share code, notes, and snippets.

@dipakcg

dipakcg/functions.php

Last active Aug 29, 2015
Embed
What would you like to do?
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