Drupal 7: how to enable\disable comment of old nodes

In Drupal 7 we can set the comments in three ways:

  • Hidden: No comments are allowed, and past comments are hidden.
  • Closed: No comments are allowed, but any past comments remain visible.
  • Open: Any future content of this type is open to new comments.

We can change in any moment the default comments' settings for any content type but the new choice will be valid only for the new nodes and not for the past ones.

If we want enable or disable the comments of a node of a certain content type then we can use an SQL qwery:

UPDATE node SET comment = X WHERE type = 'CONTENT_TYPE';
UPDATE node_revision SET comment = X WHERE nid IN (SELECT nid FROM node WHERE node.type='CONTENT_TYPE');

where comment = X is:

  • comment = 0: Hidden
  • comment = 1: Closed
  • comment = 2: Open
Tags: