Drupal - How to delete all unpublished comments?

The better way I think is to use Views and Views Bulk Operations and you can do a simple admin interface to delete all of them.

Otherwise, you still can delete directly throw a SQL query.


For those using Drupal 7, using VBO has changed and the above comments about choosing Bulk Operations as the view style is not correct. Here are the steps to create a VBO page with Drupal 7 (I'll use the example of deleting all comments)

  • Create a view where you show Comments and create a page
  • You'll need to format it in a way that allows you to add fields (table is a handy format)
  • Add a Bulk operations: Comment field and for the settings for this field, under SELECTED BULK OPERATIONS choose Delete item (you can opt to skip the confirmation step here)
  • If you have a lot of comments, under Pager for this view display something like 200 at a time (it will be slow but you won't have to repeat your deletes lots of times)
  • Save your view and then go to the page you created. You should be able to select all the items and then choose Delete under operations. You can then confirm the delete and repeat as necessary.

Tags:

Comments