Between showing the top commentators on the sidebar and the contest to win a MacBook Air I have had a lot of experience with fighting comment spam. Also from being a moderator at one of the busiest forums on the internet I have seen many methods people use to jackup their post counts. Many times people just post “I agree” or “please pm me” and I find it extremely annoying.

Forcing people to post longer comments will not help you much with automated spam (I will have tips on that in another post) but it will help you a ton with human spam. The true human spammers who were going to just type “yes” will now type “asdf asdf asdf asdf yes” and now their intent to spam is identified and they can be banned properly. The people who did not intend to spam will simply add a bit more content to their sentence. Thats the hope anyway.

So how to do it? Well I started to poke around the WordPress files looking for something that made sense and I on line 89 of the wp-comments-post.php file I found this:

[php]if ( ” == $comment_content )
wp_die( __(‘Error: please type a comment.’) ); [/php]

Aha! That makes sense. Basically that is saying if the comment is empty then invoke the wp_die function and say “Error:please type a comment”.

While their is no documentation on the WordPress function reference for “wp_die”, just by trying a comment with no content you can conclude pretty much that wp_die means show a custom page with the message we are passing and then stop.

So I added this right after that:

if (strlen($comment_content) <25 )
wp_die( __(‘Error: Your Comment Is Too Short. Please try to say something useful.’) );

What does this do? strlen is a php function that gets the “string length” then it checks to see if it is less than 25 chars. If it is it sends them to the custom wp_die page with the error message of Error: Your Comment Is Too Short. Please try to say something useful.

Now hacking on your WordPress files to accomplish a goal is pretty cool and educational BUT the next time you upgrade your WordPress your changes are going to go bye bye…

The long term way is to build a plugin. Which I asked Joost if he could do it and gave him my code. A couple minutes later he had it done. Here it is for you to download.

By Jeremy Schoemaker

Jeremy "ShoeMoney" Schoemaker is the founder & CEO of ShoeMoney Media Group, and to date has sold 6 companies and done over 10 million in affiliate revenue. In 2013 Jeremy released his #1 International Best selling Autobiography titled "Nothing's Changed But My Change" - The ShoeMoney Story. You can read more about Jeremy on his wikipedia page here.

84 thoughts on “WordPress Minimum Comment Content Length – Fighting Comment Spam”
  1. Hey, thanks for the tip! I haven’t had a problem like this in my blogs yet, but if I start to see posts like that, I will try this!

  2. wow thats what i have thought today as i have some 69000+ comments so far by Akismet but since from the past few days am getting small size comments like “is this is great”, “interesting one” all that links to spam, now i gonno try this out πŸ˜€

  3. This is a pretty cool plugin, I was checking it out on Joost’s site the other day. It sounds like it will be really helpful for sites like this one where there are comment contests etc., as well as dofollow blogs that don’t want to get filled with ‘mee too’ spam.

  4. I was tripped up by this here to other day. I added more content to the post. It is neat and should serve the purpose that you intend. The biggest problem with customizing wordpress is the upgrades, but being able to make the plugins is a plus.

  5. Great Tool !!! Thank you for that idea and big thanks to Joost too for making that so quick.

  6. I agree – comment spam is annoying…much more so, if the comment is not intellectually-stimulating…are you feeling me?

  7. It makes me laugh at how things like this often start at us right in the face and we just move along living with it. Thanks for putting a little thought into this… I have downloaded and installed πŸ™‚

  8. Does it piss you off when people keyword stuff the Name they use when they comment? This didn’t used to annoy me but I’m getting tired of ‘Coral Snake’ and ‘portland oregon web design’ commenting on my blog. My new comment policy is to change the name of the commenter slightly so they can’t get on the top commentators list and stay in no-follow hell.

  9. Awesome, I was about to go add the line of code when I kept rerading and saw the plugin! Oh how wonderful…installing now, thanks Jeremy and Joost.

  10. […] was reading the most recent post from this morning and saw that he had asked Joost de Valk to make a WordPress plugin […]

  11. I was wondering when you were going to implement this. But yeah, I think it is counting spaces.

  12. yeah i was just adding a bunch of spaces between the words. a simple check for that and you should be good to go.

  13. going to try it…I already have some plugins from Joost’s website running on my blogs. I recommend to anyone that runs WP to use Meta Robots from Joost (much more complete than All in One Seo plugin)

  14. That’s really smart! I’m not too good with PHP coding, and Aksimet doesn’t always catch spam, so this is perfect.

  15. Thanks for the tip!

    I only wish I was having this problem so I could implement this hack. Akismet intercepts my spam for me and I have yet to have a short winded poster comment on any of my posts.

    Not that I am calling my readers blowhards! I love my long winded intelligent readers.

  16. Aksimet wont catch human spam , this plugin is for humans and not bot πŸ™‚

    most bot spam are like 1000words+

  17. […] plugin today to help us in the battle against useless and unwelcome comment spam. The short comment spam solution proposed by ShoeMoney an internet marketing professional and blogger was built into a the Minimum […]

  18. Thanks for the tip along with some great insight on a lot of the real “motivation” to leave a comment on someone’s blog…. leave a comment because you want to participate, not because you want to be recognized!

    thanks again for helping to fight the good fight with this tip.

  19. Genius! I have never though about a plug-in for just that. I have noticed a lot of spammers including jibberish in their commens with tons of links. Can the code also include a max set of chars.?

  20. Although it an attempt to fight the spam comments, I doubt if it would be much effective. Spammers would come up with new ways. I am kind of surprised though wordpress does not check comment length!

  21. I was one paragraph away from finishing the read, and I thought “man, I should just whip together a plugin for this, let you set the min. comment length”.

    And then your last paragraph deflated me.

  22. After reading this post I came across an unmoderated comment that said VERY NICE!

    I then realized the link they had was to some bad naughty pictures. XD

    This plugin doesn’t come at a bad time at all!

  23. […] wurde dieses Plugin von Shoemoney, der wohl jedem Blogger bekannt sein dürfte. Der teilte seine Idee seinem Freund Joost de Valk […]

  24. My site doesnt have nearly the comments yours does I guess its a good and bad thing to have so many people placing comments on your site. I wish there were more “plugins” for blogger sites, or I wish it were easier to change from blogger to wordpress, seems all the good advice is for wordpress blogs.

  25. I like the way you think. I was thinking “Okay, this is great, but the next upgrade will override these settings”, but voila – you put a link to the plugin version. I’m implementing this right away. I hate when people leave comments like that, if you even call them REAL comments.

  26. i thought you dont moderate comments here in your blog… well dp is really a hard task.. well i think they have somehoiw changed their policy there…

  27. Great idea, I have been getting bombarded by manual comment spammers as of late so it probably won’t help to much since most of them are already writing longer comments.

  28. People that spam others are just Internet stupid. The backlash against these people is getting so big that as soon they will be getting caught faster and faster and going to jail for years. People need to think about the consequences. Only problem is a lot of people don’t care.

  29. I love little hacks like this, thanks for sharing. WordPress is such a powerfully supported tool, it’s hard to me to understand why simple things like this is left out.

  30. Great tip, thanks for sharing and for making it into a plugin. I wonder why simple stuff like that is left out by the wordpress team…

  31. Cool plug-in to fight a growing issue. I will be adding it to my blogs, it should save a bit of time.

  32. I always enjoy snooping around the WordPress files, that’s how I found out how to remove the update nag that shows when a new WordPress version is available.

  33. aha, lol! very good way to keep spammers away. Thanks j for sharing this. I hope that my comment is Ok πŸ˜›

  34. Fighting comment spam is a bit like the cold war – for every advance made the spammers up the ante by finding ways around. Its going to be a long time before human moderation can be replaced but nice plugins like this will help reduce the workload by stopping the majority of the spam.

  35. Well blow me down and call me a dumb Aussie Blogger. Isn’t it amazing how something so small can make such a big difference. I reckon I will give this plugin a go. Thanks for the tip, oh and it goes without saying ‘nice blog’ πŸ˜‰

  36. Yeah thanks for the tips and sharing this lovely piece of code. Fighting Spam is one of the biggest challenges now actually!

  37. […] mit einem Link finden sich mittlerweile unter vielen Artikeln und deshalb gibt es bei Shoemoney ein kleines Plugin, das genau diese Art der Spamkommentare verhindern soll: Minimum Comment Content […]

  38. Is there anyway that you could redirect this haphazard spammer to a youtube video of rick astley?

  39. I agree, this is a very useful thing. Spam is growing exponentially proportions in recent times. Thank you, Shoe.

  40. Yeah, I agree, you should rickroll him hahaha. Yeah it’s a good thing to have the spam check in place on a WordPress blog with all of the comment spammers out there.

  41. […] nachdenken, wie sie das Problem in den Griff bekommen kânnen. Seit einigen Tagen ist es angesagt, besonders kurze Kommentare (kleiner 25 Zeichen) automatisch als Spam zu markieren und herauszufiltern, damit man Kommentare […]

  42. I posted on another story and my comment never showed up. It was rather long. If you can’t read this, it means that this one didn’t show up either.

  43. […] This is the 2nd post in a series on how to fight wordpress comment spam.  You can read the first post on minimum comment content here. […]

  44. […] This is the 2nd post in a series on how to fight wordpress comment spam.  You can read the first post on minimum comment content here. […]

  45. […] has two good posts about simple fixes to reduce comment spam on your blog. One is a minimum content requirement, and the other is using the WordPress discussion […]

  46. Jeremy, Excellent! I have just created a blog to learn WordPress, and am using my reviewing products from ClickBank promotions, with the link embedded in the body text of the post. You have a great friend there in Mr. Joost.
    Respectfully, Nicholas [The Guitar Blog]

  47. […] WordPress Minimum Comment Content Length – Fighting Comment Spam […]

    1. Databases can provide you with a wealth of sources to examine, and some of them are even keyword searchable. ,

  48. PCO judge who could have a dissenting opinion which could be used by anyone to challenge the order. ,

  49. I confess, I have not came to this blog in a long time. even so it absolutely was one more joy to read your fantastic articles.

  50. Wow! Thank you! I continually wanted to write on my site something like that. Can I include a part of your post to my site?

  51. thought seo because you receive on understand is that in that place are a piece of land of sites out in that place because simply seo require into seo demand your seo coin.

  52. Asian Traveler…

    […]here are some links to pages that we link to because we think they are worth taking a look at[…]Ò€¦…

  53. you are really a excellent webmaster. The web site loading pace is amazing. It sort of feels that you’re doing any distinctive trick. In addition, The contents are masterwork. you have done a magnificent job in this subject!

  54. Almost every business no matter how big or small needs an online presence. Have you noticed that internet connections are becoming as common as phone lines? Web based business…

  55. You really should post more often. I actually have not a single thing better to do.

  56. Can I simply say what a relief to discover an individual who truly understands what they’re talking about on the net. You certainly know how to bring a problem to light and make it important. More and more people have to read this and understand this side of your story. It’s surprising you are not more popular because you most certainly have the gift.

Comments are closed.