3

Having just relaunched a site containing a decade of content, I'd like to close comments on everything over a couple years old.

I thought there was something built in, but either it's not there or I can't find it.

Is there an add-on? Or a simple sequel statement?

6

There is a setting under Admin → Channel Administration → Channels → Edit Preferences - under the Comment Posting Preferences header - for Comment Expiration.

Set a number of days there, and tick the box for "Update all existing comments with this setting" (which should more accurately read "existing entries").

Screenshot of setting

To be clear this won't close all comments, but remove the ability to comment on all entries which fit the criteria. (Your question uses the phrase "close comments" but I'm pretty sure you don't actually want to remove the old comments?)

  • You're right, this is what I was after. Many thanks. – Tim Jan 29 '13 at 20:36
6

Given that the control panel for comments (Add-ons > Modules > Comments) is a little limited in its date filtering, and if you have lots and lots of comments it would be a chore, a query is probably the best route.

A query that would close all comment entries before Sat, 01 Jan 2011 00:00:00 GMT:

UPDATE exp_comments
SET status = 'c'
WHERE comment_date < 1293840000

OR...If what you meant was to not allow new comments on entries older than two years then here is a query to do that (or just see @Derek's answer!):

UPDATE exp_channel_titles
SET allow_comments = 'n'
WHERE entry_date < 1293840000

You can use Epoch Converter to get a Unix timestamp for your comment cut-off date.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.