After getting more and more annoyed at the prevalence of comment spam, I went hunting around for a good way to automatically close comments on entries here after a certain number of days. What I stumbled upon was a few semi-manual ways, and after tweaking them a bit and adding an automation step, I have a system in place (and a publicly-available script) that will turn comments off after 60 days.

I started off by playing around with David Raynes’s MT-Close, but didn’t like how I didn’t get much in the way of feedback and that it wouldn’t be trivial to automate. That led me to a bit more Googling, which pointed me in the direction of a PHP script by Kevin Schumacher that will close comments after however many hours or days you choose. I ran it once, though, and noticed an issue — the script sets comments to closed on all entries older than the specified age, even if they never had comments enabled in the first place. And while this is a small point, it didn’t work well in my layout (the comment banner would be added to all these entries, and I didn’t like that). Likewise, the script didn’t differentiate among different weblogs on the same Movable Type installation, instead closing comments on all weblogs at the same time.

Happily, Kevin released his script under a license that lets me modify it, so I did, and created a derivative version that correctly handles individual weblogs and the difference between comment-enabled and comment-disabled entries. It’s closecomments.php version 1.1JL, and it’s released under the same (well, updated) Creative Commons license — the Attribution-NonCommercial-ShareAlike license.

There were two remaining problems — I still needed a trigger to run the script, and then I needed a way to force a rebuild of the affected entries so that the comment form would be removed from the entries’ archive pages. I found a solution to both in a posting by Chris Hilts — he suggested a cron job that called the closecomments script, and the mt-rebuild script which could be called immediately afterwards and would handle the rebuilding.

And there you have it — an automated way to close comments after 60 days, all in an effort to give the comment spammers a few less targets. I hope that it’s useful to other people!

Comments

I’m glad you found my page useful. Would you mind correcting the last name from Mills to Hilts? Thanks very much!

• Posted by: Chris Hilts on Sep 1, 2004, 11:14 PM

Done — sorry ‘bout that!

• Posted by: Jason on Sep 1, 2004, 11:19 PM

Thanks for this. Ignore my other comment (on MT-Blacklist) asking “how’d you do that?”.

• Posted by: James McNally [TypeKey Profile Page] on Sep 10, 2004, 11:03 AM
Please note that comments automatically close after 60 days; the comment spammers love to use the older, rarely-viewed pages to work their magic. If comments are closed and you want to let me know something, feel free to use the contact page!