You are here

Bulk update comment settings on multiple nodes - Drupal

category: 

Recently, I needed to archive the blog section of a Drupal site. Part of this included removing all past comments and removing the ability to leave new comments. Removing comments is pretty easy in Drupal. There is a comment management section for that.

However, to remove the ability to comment on published nodes requires a bulk update. This is something that is not available in the standard Drupal site. Therefore, I had to resort to an alternative method of bulk updating the blog posts.

The Solution: Bulk update the tables using phpMyAdmin.

Steps:

  1. log into your phpMyAdmin
  2. Select the database your website is using
  3. Click the sql tab
  4. enter your UPDATE code in the field and submit

The UPDATE code I used:

UPDATE 
  node 
SET 
  comment = 0 
WHERE 
  type = "blog"

Update

Basiacally, we are going to update nodes.

Where

As stated earlier, I was updating the blogs. However, if you want to update a different node type/content type you would need to change the value of "blog" to the node type you wish to update. 

Set

You may want bulk update the nodes to allow commenting or restrict to read only.  This break down should help you adjust the values.

0 = Comments disabled
1 = Read only 
2 = Read and Write

I am no sql expert, but this snippet of code has helped me many times. Therefore, I thought I would share.