Very *effective* antispam trick on blogs

Most of bloggers have a problem with spam. Of course, there is Akismet, but sometimes Akismet is not good enough because he doesn’t catch all spam messages. So, with this in mind, i wanted only to get rid of all automated messages.

So, look what i did:

First of all, i go with „robots fills ALL fields with something” in my mind. I’ve added only TWO lines of code: one in comments.php from your theme folder and one in wp-comments-post.php from your root folder.

Ok, how you do it?

First of all you need a ftp client and a text editor. E-texteditor is 2 in 1 so you can download a trial version for doing this. Ofcourse, you can use the old and ugly notepad (or whatever your OS has default).

Open comments.php (which is in your wp-content/themes/your_theme_name folder) then find this line:

Some things can vary (like ID of the form), but 90% in cases you won’t need to look for something else ;)

Just AFTER this line you add:

Don't fill this!

We put a form here and hide it. I didn’t use display:none because i wanted to be sure that field will be showed up, even is on the left side of the screen (you should actually turn you head to left to see it :P ) So the bot will actually SEE that form and will fill. Normal user won’t.

Save and upload (or just save if you work directly on ftp) then open wp-comments-post.php from your root folder. Just after the


beginning part, just add this:

if( $_POST['name2']!= ''){
	die('Spammer!');
}

Save and upload.

Next you need to... Hmm... You don't need to do anything else ! Now empty your Akismet queue and wait to see if you get any other spam messages ;)

Note that is possible to not catch ALL spams, but those are automated you won't get it anymore :) Also, when you upgrade wordpress make sure you make those changes again. And finally, BACK UP FIRST!

Update.

READ THIS!

Verry annoying thing that i had recently noticed: even if this small plugin do a great job for spamm *comments*, will NOT work on trackback spam.

No related posts.

12 thoughts on “Very *effective* antispam trick on blogs

  1. Ionut, te iau pe romana, nu prea stiu sa explic pe engleza. Deci am facut exact cum ai spus tu, acuma deschid wp-comments-post.php dar unde adaug aia cu $post die spamer etc. La sfarsit? Multumesc!

  2. I would’ve done something like header(“Location: someanimalpornurl.com”); instead of the die() line :) Great idea, congrats!

  3. Pingback: Usability fail | Staicu Ionut Bogdan

  4. Pingback: Ntz Antispam Plugin | Ionut Staicu - Webdeveloper Blog

  5. Hi Li-An and thanks for comment. I also did a plugin for this (you can find it HERE).

    I didn’t know there is something similar, but, after you take a look in antispam-bee code and then in my code you will see the difference :P

  6. Pingback: Plugin antispam pentru Wordpress « Cosmin Chiru

  7. I’ve first seen this idea on this blog quite a while ago: http://www.ad7six.com/MiBlog/Spam
    I’ve been using it for quite a long time, works great, the only issue is that some form-filling applications automatically fill all fields containing ‘email’ in their name, therefore triggering false positives from time to time.

  8. Pingback: How to: anti-spam eficient in WordPress

Leave a Reply