2

I have a relentless human spammer that is extraordinarily difficult to keep away. Spam filters are unhelpful as he does not use a set of frequently used words. Rather, his insults are more "subtle" to be captured by any regext. Each time I block him, he comes back with a new username but soon the new user reveals his spammy nature. So I need to go through the list of comment to finds the one by him and delete them one by one. On the other hand, I don't want to disable comments auto-approval just because of one bad apple.

It is painful especially when you need to do it a couple of times a day! so I wish there was an easier way to sort and then delete comments of a particular user, and not involved direct querying the database?

  • 1
    Along with deleting the user account you can also ban the IP address which was used. – 15dk51 May 30 '11 at 14:55
  • Banning IP or deletting the user are not very effective solution if the bad guy is too determined. He can easily come with other username and use proxy to change the IP. – alfish Jun 1 '11 at 12:59
4

Using Views Bulk Operations, you can create a view for all the comments written by a user, which allows you to delete all the comments written by a user without the limitation of deleting them in groups of 50 at time. When you click on the button to select the comments shown in the pager's page, you are asked if you want to select all the comments; in that way you can delete all the comments with a single click. As the view can be set to use batch operations, it is able to delete a great number of comments without any timeout.

You can create a view that is shown in the user profile page (as done on Drupal.org), or you can create a view that replaces the page shown in admin/content/comment. Being a view, you can filter the comments listed using different criteria, such as the content type of the node for which the comments have been created, the author of the comment, the author of the node to which the comment is attached, etc.

Views Bulk Operation doesn't come with a custom view to show the comments made from a user; it comes with a view that can be used to replace the page shown at admin/content/node. Using that view as example, you can easily build the view you need for the comments.

Drupal.org screenshot

| improve this answer | |
  • I could not figure out how to make this view. Can you elaborate on this please, or refer me to a suitable link? – alfish Jun 5 '11 at 10:17
2

You can quite easily delete comments with a bit of PHP, for Drupal 6 it would look like this:

$uid = xx // the spam users id;
$query = db_query("SELECT cid FROM {comments} WHERE uid = %d", $uid);
while($cid = db_result($query)) {
  comment_delete($cid);
}

For Drupal 6 there is also the alternative way of dealing with trouble users like this, by bringing misery upon them. Banning their IP address might be a bit more effective though.

| improve this answer | |
  • where shoudl I execute the php code? – alfish Jun 1 '11 at 12:57
  • @alfish You could use drush. – googletorp Jun 1 '11 at 16:45
  • I get this error when I execute your script in drush: Error: Call to undefined function comment_delete() – alfish Aug 23 '11 at 13:47
0

A solution to attack the root of the problem:

Drupal offers the option of banning an IP in Users -> Access Rules -> Add Rule -> Deny Host

To know the IP of the user -> In the report logs you will see "Session open for user" messages. Click it and you will see the IP of that user.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.