Monday, October 10, 2011

Delete un-approved comments in Drupal7

The story is like this, while managing the drupal7 instance for I kinda saw 900+ un-approved comments that where most likely spam. Not wanting to scroll thru all the pages and select/delete each comment I found the below very convenient solution :

1. Backup the drupal7 db table used for comments :
mysqldump -u -p drupal_database comment > comment_table1.sql
or the entire database

mysqldump -u -p drupal_database  > drupal_database.sql

2. Remove all of the un-approved ones :
- additional step here is to check the exact status of what you are deleting : 
select * from comment where status=0 limit =10;
delete from comment where status=0;

3. Check the website, and probably enable/install captcha, or have some notifications setup for each comment added.

No comments:

Post a Comment