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

Sorry but comments on this post are now closed.