WordPress.org

Ready to get started?Download WordPress

Forums

Setting Blacklist to auto-block (2 posts)

  1. Kaimipono
    Member
    Posted 9 years ago #

    I like the WP blacklist, but we get a lot of spam, and I've been getting tired of deleting moderated comments. So, I made the following change to blacklist, and thought it might be something that others would be interested in.
    To automatically block spam (kind of like MT Blacklist, but not quite the same), I did this:
    First, I had WP-Blacklist set up, with the default settings. (If you've modified the settings, adapt the information below as necessary).
    Second, I altered the wp-post-comments.php file, which read:
    $blacklists = $wpdb->get_results("SELECT domain FROM blacklist");
    foreach ($blacklists as $blacklist) {
    $regex = "/".$blacklist->domain."/i";
    if (@preg_match($regex, $url))
    $approved = 0;
    if (@preg_match($regex, $email))
    $approved = 0;
    if (@preg_match($regex, $comment))
    $approved = 0;
    }
    Replacing each instance of
    $approved = 0;
    With this:
    {
    echo ('Your Comment: ');
    echo ($comment);
    echo ('<br><br>');
    die( __('Sorry, but some of the content of this comment appears to violate our comment policies. This determination has been made using filtering software. If you believe you have received this message in error, please contact us by e-mail as soon as possible. In addition, please note that this comment will not be saved on our server. Therefore, if you wish to preserve any of the content of this comment, you should copy it from this screen right now. Thank you.') );
    }
    That's it.
    And, of course, you can modify the setting as desired. Frankly, you could just set it to die if it's got a blacklist match. But I strongly wish not to kill legitimate comments. And the die means that there's no chance to get the comment back. So, as currently set up, it echoes the comment (and warns the commenter), giving the commenter a chance to save the text if it's legit.

  2. Kaimipono
    Member
    Posted 9 years ago #

    I changed it again, adding the following just before the die, to help for figuring out when any comments were creating false positives:
    echo ('Reason Blocked: ');
    echo ($regex);
    echo ('<br><br>');

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.