Timed disabling of WordPress comments

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s