Bulk Delete of Unapproved Comments in Drupal 7

  • Posted on: 13 January 2013
  • By: Pradeep George

When you allow comments in your blog post or page, often you will be spammed with thousands of comments from spammers. One way to reduse it to use module like CAPTCHA.
IF you already have thousands of comments to your posts and would like to remove all the un approved comments here is the method.

1. Enable the PHP format in your site
2. Create a new content page and add the following code

db_query('DELETE FROM comment WHERE status = 0');

3. Select your text format as PHP code
4. Save
5. Reload the page

That should run the php code and remove all the un approved comments from your database.


Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.