Protect your wordpress wpadmin panel

0.88K views
no comments
21 Feb 2018 2:16 am

users can easily access or hacker’s programmed bots will send login request to your yoursite.com/wp-login page, but #wordpress have a good security with admin login panel, I have a wrote little code using #wordpress #hooks to prevent from other all users from your site wordpress wp admin login page.

Prevent users and programmed bots from your wordpress wp-login

function login_redir(){
	error_reporting(0);	//make error reporting off, header function will thrown warning if already header sent.
	if($_GET['mylogin'] !=='your_any_method'){
		$siteurl = get_bloginfo('url');
		header("location:".$siteurl);
		//Force to redirect to main domain if php header function cannot redirect.
		echo '<script>window.location = "'.$siteurl.'";</script>';
		die();
	}
}
//add_action to register function
add_action('login_head', 'login_redir');

copy this code and paste into your #theme functions.php file.
Note:after integration of this code you cannot view your wp-login page for login, can you use yoursite.com/wp-login.php?mylogin=your_any_method

 

Here screenshot of hacker’s programmed bots attacks

programmed bots attacks on wp-login

NOTE:Your Email Address will be not shown and please do not add spamming comments because here is REL="NOFOLLOW" on your links and comments also moderated shown.
<code>Put html css or any language code under this tag</code>