How to restrict/whitelist email extensions on your contact forms for your wordpress membership site

Posted on

Hi all, today a client in a very targeted niche requested a filter on their website membership form so only certain email extensions could successfully join their site. This ensures that only companies they are affiliated with can register to their site and view their locked down content, and also keeps out any spam or users who are not supposed to access this site.

Today, i’m going to show you how I setup the site using the Wpforms Pro plugin, which you can purchase here. This guide that is coming is posted here, but I am doing a walkthrough as for this particular project the client is using Buddyboss platform as a membership site, which is not outlined in the Wpforms guide.

First, you need to download and install the WP forms pro plugin.

Once you have done that and activated your license, you need to go to add ons and install the user registration extension which looks like this:

jane james wordpress developer user registration wp forms

Now you need to add a new form and choose the user registration form template:

jane james wordpress developer user registration wp forms template

Once you have selected the user registration form, go ahead and populate it with the fields you require.

jane james wordpress developer wpforms user registration

And finally, make sure to configure the notifications and confirmation settings.

jane james wordpress developer confirmation forms

Now, we’re going to add the whitelist of allowable domains to your functions.php file. You can copy the gist below, and in the array replace ‘icloud.com’, ‘me.com’ with the email extensions you wish to whitelist.

 

The whitelist contains ‘allowable’ email form fields, but if your list of extensions is very large, you may wish to just add a blacklist instead, which is likely to contain less extensions. Once again, change the values to the email extensions you wish to whatever values you wish to blacklist.

And that is it! Simple easy, and only requires a few modifications to your functions.php file.

For the particular project I used this for, all users on the whitelist who register for the membership site, are then automatically joined to the backend BuddyBoss platform. As BuddyBoss has an integration with WPforms, there were no further code snippets or plugins required to achieve this.

Happy days! If you gave this a go and got it working (or not) please comment and I’d love to hear from you or help you out.

Jane James is a WordPress web developer based in Melbourne, Australia but also services clientsfrom Sydney, Brisbane, Newcastle, Perth, Adelaide, Darwin and Hobart.

© Alpha Omega Digital, Melbourne Australia 2024 | All Rights Reserved