Menu Home

Making WordPress invite only

Tijs recently got WordPress installed on his website, so over the last couple of days I’ve been helping him set it up with a gallery. By the way, I have used pretty much every gallery plugin and in my opinion the best by far in terms of drop-in-and-it-just-works is lazy-k. If you’ve got wordpress and a need for a simple gallery, give lazy-k a look. I use a simplistically setup version on blundells.co.nz.

Anyway, Tijs had an interesting conundrum – he wanted the site to be friends/family only, no public viewability. This was easy enough with Angsuman’s Authenticated WordPress Plugin But then Tijs upped the bar. The plugin linked to wp-login.php, which was devoid of registration options. And Tijs didnt want joe.public to be able to register and then view his privates. So “Anyone can register” was disabled in the Administration panel, and I went about looking for a way to create a contact form.

I decided to hack it into wp-login.php, so that when people tried to go anywhere on Tijs’ site, they’d get redirected to a single page that gave them the option to either login or send Tijs an email via a contact form requesting an account. This way Tijs could control who did and who didn’t get accounts, and it kept it simple from a usability and coding point of view.

After trying to modify some WordPress contact form plugins, I gave up and tried to find a simple and secure php contact form. After checking out a few, I came across phpformmailer which appeared to be ideal. Simple and a basic level of security with some built in fault checking.

It arrives with two files, contact.html and contact.php. contact.html takes the input and posts it to contact.php which then processes it. So it was a matter of taking the form from contact.html and adjusting it to fit into wp-login.php

Here’s what I came up with, most of the work is towards the bottom of the file, between html comments declaring it a contact form:
textfile.jpg

You have to add a class to your wp-admin/wp-admin.css file to make the form look like the standard wp-login.php stuff, thanks to Spoon for the hand here.

.xboxlol {
font-size: 1.7em;
width: 80%;
}

Then just create and configure contact.php as per the phpformmailer instructions. Now if you try to access your site, the angsuman plugin will redirect you to wp-login.php, and you’ll get something that looks like this:

tijssite.jpg

1 reply