As I am writing this blog post about preventing spam registration on wordPress, many weblogs out there are getting tons of new accounts registered which belong to robots and are totally untolerated spam.
Preventing Spam Registration on WordPress
There are so many ways out there, free and paid, which would help you knock off spam registration on your WordPress blog or website. One of them is CleanTalk, I love this one as it has a great database of malware checks (blacklist) and many online ready tools to verify a user before it successfully signs up.
But for me, I always prefer not to add another plugin to the load, so if it was to coding a little snippet of script that would help then that would be super. So hopefully this could help out preventing spam registration somehow.
Every time the registration screen is requested, the form field for spam check will be added on window load, and it will be required to process the registration.
Once the field was not added, the request will be killed with a simple error message:
Or possibly if you don’t want to kill the request but show a warning message notice instead, comment out wp_die function and remove the comments for $errors->add method usage in the script code; inside se_nospam_register_validate callback function, and this would appear:
Cool! now where can I get the plugin? (no plugin, just some small snippet of non commented code) ; read on.
Preventing Spam Registration on WordPress: The code
You can use the following code to be added to your child theme’s functions file, or download the plugin from Github gist:
Cool! if preventing spam registration on WordPress with this custom trick has worked for you, then that’s what matters! Yay!! Personally it helped me a lot on my product support forums website where I have bbPress installed for the forums functionality.
Preventing Spam Registration on WordPress: After
Saying that it was helpful to preventing spam registration, there should be more to do after this, right? I mean like, capturing the prevented spam registration attempts and saving some count to the database so you can see a log of how many spam bots were blocked; something like adding this code:
update_option($name = 'se_how_many_spam', intval(get_option( $name )) + 1);
That to be added right before each wp_die in the code, And then calling
get_option( 'se_how_many_spam' );
to tell how much spam was denied. Also you might want to capture the user IP to block them or something, as long as possible, saying that spam can never be tolerated. (beware, bots will call you agressive then)
That is it for this tutorial and I am hoping this helps you as it helped me and if there is any improvements or suggestions and ideas to implement, please feel free to discuss in below comments.
Cheap Cloud SSD Hosting
Get a VPS now starting at $5/m, fast and perfect for WordPress and PHP applications