Skip to main content


Drupal module: Advanced Comment Trigger

Posted in

I have to admit that I've got it pretty good in the website spam department. The Mollom project, started by some of the same folks who started Drupal, uses content analysis to keep spam users from registering accounts on my site, leaving blog & forum comments, and using my site's contact form to spam me via email as well.

The only problem that I've really seen is the rise of spammers who will post blog comments containing text from the blog post itself, almost entirely unchanged, along with one or more links to their sites. Content-based analysis is of no use here, since the majority of the comment is actual text that I would want on my site -- after all, I blogged it!

Until now, I've been following all blog comments to my site via built-in RSS feeds, noticing spam comments some time after they were posted, and going back and deleting them. Drupal allows for comment moderation, but I want comments to go out there right away.

Drupal also allows for some advanced responses using triggers and actions. I could define a trigger such as "comment contains http://" and then assign it an action such as "unpublish comment". In fact, this is what fellow Cocoa developer and Drupal user David Sinclair of Dejal Systems does currently.

But this presents a problem in my use case, as i want to publish comments of my own sometimes containing hyperlinks. Also, I don't have a problem on my forums, just on the blog.

After some back and forth with David on Twitter, I decided to set out and build a small module to help with this. About twenty-four hours later, I give you: Advanced Comment Trigger.

After enabling the module, head to the trigger configuration in Drupal, then the "Advanced comment trigger" tab. Assign the new trigger to the "Unpublish comment" action, then follow the link to fine-tune the module settings. You can configure the trigger to occur on anywhere from one to five or more hyperlinks in the comment body, as well as exempt certain user roles (for example, site admins) or certain content types (for example, forum topics) from triggering the action.

trigger & action configuration

module configuration

I've also included the source to a Drupal view to create an RSS feed of moderated comments so that you can easily follow the comments to which the trigger applies. Checking this from time to time will allow you to easily publish any comments that accidentally get moderated, as well as get an idea of how well this module is working.

In the near future, I hope to add a few more available actions to the trigger such as emailing a site admin or post author or blocking an offending commenter.

Feedback is welcome. You can follow the project at the Drupal project page or on GitHub.

Mollom anti-spam service is out of beta

Like many other people, I received an email this morning announcing that Mollom, a project of Drupal founder Dries Buytaert, is out of beta. I use Mollom on this website, as well as another personal one, to reduce and sometimes outright eliminate blog comment spam. In my configuration, Mollom works by using heuristics against blog comments and if they are considered spammy enough, the user is challenged to a simple CAPTCHA system to prove that they are not an automated spammer.

Mollom is a great system, since some studies (direct PDF link) have shown that as much as 75% of all attempted comments on blogs are spam!

I've been using Mollom for a few months and have been very happy with it. If you run a blog, even one that isn't in Drupal, I would encourage you to check it out. It's free for many uses, so you lose nothing by at least giving it a shot. There is a developer API and Mollom has already made downloadable integration available for Drupal, WordPress, and Joomla, as well as language-specific libraries.

Congratulations to Dries and the Mollom team! I look forward to the system only getting better as more and more folks start to use it.

Update: A couple folks asked if I'd mind posting my Mollom statistics graph, so you can find it here. There were many hundreds of spams stopped in the past month!

Syndicate content