WordPress.org

Ready to get started?Download WordPress

Forums

[1.2] Delete spam-comments instead of just queuing them! (6 posts)

  1. raskall
    Member
    Posted 9 years ago #

    I do not know where to post hacks, so I post it here in the support forum.

    I am under constant "attack" from spammers trying to post a lot of comments in my wordpress-blogs. The clostest thing to getting rid of these was entering words into the setup to get them into the moderation queue instead of being posted directly.

    First I created a mysql cron-job to delete all comments with the field comment_approved in table wp_comments equal to 0. This deleted all the unwanted posts, but I still got >25 emails a day telling me that a comment expected approval.

    So I opened the file wp-comments-post.php and browsed through it and found the test that sent the notification email to the blog owner.

    I changed the following:

    if (!$approved) {
    wp_notify_moderator($comment_ID);
    }

    to:

    if (!$approved) {
    $wpdb->query("DELETE FROM $tablecomments WHERE comment_ID =$comment_ID");
    }

    And I got rid of the cron-job, notification mail and most importantly the unwanted comments. :)

  2. Guss
    Member
    Posted 9 years ago #

    Wouldn't that simply remove delete all unapproved comments, w/o allowing legitimate users to post comments ?

    If so then what is the point in enabling comments at all ? just disable the comments for your posts and be done with it.

  3. DianeV
    Member
    Posted 9 years ago #

    Interesting idea, though. If it could delete comments awaiting approval that contained any of the words/elements in your Options/Discussions/Comment Moderation box, that might be interesting.

  4. raskall
    Member
    Posted 9 years ago #

    That is exactly what I have done. I allow all comments, but the ones containing words/elements from Options/Discussions/Comment Moderation box is now simply deleted during posting.

    But it requires comment moderation to be turned off. Now everyone can post comments without registering, but comments containing unwanted words is deleted instead of put in the moderation queue.

  5. TechGnome
    Moderator
    Posted 9 years ago #

    It's nothing new..... SpamKarma does that for me as well.

    Tg

  6. pericat
    Member
    Posted 9 years ago #

    It's not new, but it is a different approach that may suit some people better than using a plugin such as SpamKarma. raskall has essentially hacked wp-comments-post.php so as to treat the moderation list as a blacklist.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.