Delete all spam node entries of a spesific user on a Drupal site with PHP

Submitted by Anonymous (not verified) on Thu, 02/02/2012 - 16:00

Case: We have one or more spammer-user who added hunderts/thousands of nodes automagicly or manually. It takes very long time to delete them using Drupal admin interface. We need a fast & effective solution.

The solution
1. Find 'uid' of spammer
2. Create a block with input-filter PHP and run following code

<?php
$r
= db_query("select * from {node} where uid='123456789'");
while(
$arr = db_fetch_array($r) ){
    echo
$counter++. " ". print_r($arr,1)." <hr />";
            echo
node_delete( $arr[nid] );
}
?>

Add new comment