jump to navigation

Timed disabling of WordPress comments September 6, 2006

Posted by dllh in flock.
trackback

I wrote the other night about my frustration with comments in WordPress. The anti-spam tools that come with the software are great for squashing spam, but I still occasionally go through periods during which I get a bunch of emails asking me to log in and moderate spam, and that irritates me. Most of these moderation requests are for spam on old posts. So I decided to write a WordPress plugin that would auto-disable comments and pings on old posts. This allows me to keep comments open for those who read my stuff and would like to comment within a reasonable timeframe but keeps me from having to go back and manually run mysql queries by hand (or, worse yet, manually edit old posts) to turn off comments on individual posts. (The WordPress options for commenting affect only future posts.)

The plugin is a simple one, providing an option under the “Manage” and “Manage Comments” administrative screens allowing you to set the number of days old a post must be to have its comments disabled. If you post infrequently, this plugin won’t do you much good, as its action is triggered by the saving of a post. If you post every few days as I tend to, though, it’ll do an ok job of keeping old posts from picking up comment spam. The default threshold is 14 days. So any time I add or save a post, WordPress runs a query that disables comments and pings on all posts created more than 14 days ago. That’s all there is to it.

Download the plugin here if you think you’d find it useful.

Comments»

1. Brent O. - September 6, 2006

When you said “timed disabling”, I thought you meant you had a Slashdot-style timer on the server side that wouldn’t allow a user to submit a form less than X seconds after the server sends it to them. That sounded nifty too! :-D

2. dllh - September 6, 2006

In theory, that’d be pretty simple to add. Just add a hook to the comment posting that sets a session variable on page load, and check that variable on comment submit, bouncing back with an error if appropriate. It’s not something I’d find especially useful for my site, though, so I won’t be writing it. :)

3. Duncan - March 27, 2007

Wow, old post… oh oh. A comment :-P
I’m obviously having the exact same problem you did. Thanks for the plugin

4. Test - March 30, 2007

Hi

Bye

5. Dr.Dorcell - May 2, 2007

6. private medical insurance - May 29, 2007

private medical insurance

instigating Gershwins ranging amiss