How to: Only allow yourself to login to WordPress.
So I was just casually sitting here minding my own business this evening, working on a top secret project when all of a sudden my email alarm went crazy. Yes I have an alarm. A lot of the time I pass most of these bells and whistles off as spam, and close my e-mail client. However this time I decided to actually check, and lo and behold, a message from Flyninja.net.
Now this was no ordinary e-mail, such as for a new comment, or a new post from one of our contributing authors. No. This was to notify me that my password had been forgotten by someone else, and had been reset. That is an annoyance. Oh but what to do? What to do?
I decided I would add a few lines of my own code to the login page. This code checks for a specified IP address, and if it is not the defined IP, redirects the person somewhere else. All in a couple lines of code.
Before I divulge this little trinket, letme just clarify that it’s very generic, and simple. If you are the only person who posts to your blog, this is great. If you have more than one author, then it will need a bit more added to it. If you don’t have a static IP, then this probably is not a good idea for you.
Open up wp-login.php in your favorite editor and find the line:
add_action(‘login_head’, ‘noindex’);
This is found within the Function ‘login_header’ and may be about line 49
Beneath this line add this code:
$data = ‘you.ip.add.ress’;
if ($_SERVER['REMOTE_ADDR'] != $data) {
header(‘Location: http://www.somewebsite.com/’);
}
$data should equal your IP address, and after Location: you should add a website which you would like the stupid fucks who attempt to login to be redirected to.
