Perform a redirect when you log in to WordPress wrong

Dismiss an unwanted user who tries to access the admin panel

These days my blog is receiving several authentication attempts to access the control panel. Honestly, I don’t know yet if it’s a bot or a human being continually logging in incorrectly, but I’ve found a way to turn off the visitor who tries to access my control panel.

The system is very simple:

  • The visitor arrives at the login panel of the blog
  • Enter an incorrect username and password
  • It is redirected to a page set by you, possibly also to an AdFly link so that you can also pay for its access attempt

How you do it?

Edit your theme’s functions.php file, and add these lines

add_action( 'wp_login_failed', 'redirect_personalizzato_per_login_fallito' );
 
function redirect_personalizzato_per_login_fallito( $username ) {
	$referrer = 'http://new_link';
	wp_redirect($referrer);
	exit;
}

Instead of http://new_link, insert the link where you want the user to end up after entering the wrong credentials, for example on the purchase page of your book, on an advertising circuit, or on your Amazon referral.

Seeing is believing.

We periodically check the functioning of the links in our articles. If you notice any links that do not work, please let us know in the comments. If you enjoyed the article consider supporting the blog with a small donation. Thank you. Patreon / Ko-fi / Liberapay / Paypal

Leave a Reply

Your email address will not be published. Required fields are marked *