Peter's Blog

Redefining the Impossible

Mass deleting unapproved Drupal comments


The following will mass delete unapproved drupal comments, especially accursed comment spam. It is a quick and dirty sledgehammer approach, no subtlety.

  • Create a file in your root directory called, say, killspam.php containing the following:
    <?php
    include_once 'includes/bootstrap.inc';
    include_once 'includes/common.inc' ;
    
    db_query('DELETE FROM {comments} WHERE Status = 1');
    
    echo( "Done");
    
    ?>
    
  • Go to {your website name}/killspam.php in a web browser.

This should result in your unapproved comments being deleted. Note that there is no access control here, anyone can do it. Better to restrict access to the kill file or give it a name that no one can guess.


Filed under: drupal php

Have Your Say

I welcome constructive comments or questions but I reserve the right to delete any comments that displease me.

Who are you?

(Optional) If you enter an email address here I might email you back. Your email address will not be sold to spammers or shown anywhere

What do you have to say?