WordPress.org

Ready to get started?Download WordPress

Forums

Override Comment Blacklist (4 posts)

  1. rtcunningham
    Member
    Posted 4 years ago #

    This is the function, with various parts changed for privacy (a private spam blocking list or SBL). I already use it block connections from undesirables before WordPress loads, but some of them still manage to get through (proxy or whatever) and the blocked IPs or domains still get posted. I want to hook into the comments blacklist and stop them there if they make it that far. Here's what I have and the question is how do I populate the author variables? Am I using the right filter?

    ***

    function sbl ($approved) {
    $a = file_get_contents ('http://my.domain.com/check.php?ip=' . $comment_author_IP . '&ref=' . $_SERVER['HTTP_REFERER'] . '&uri=' . $comment_author_url); $a = trim($a);
    if ($a == 'ip' || $a == 'uri') {
    $error_message_detailed = 'Your comment has been blocked based on the blog owner\'s blacklist settings.

    If you feel this is in error, please contact the blog owner by some other method.

    '."\n";
    wp_die( __($error_message_detailed) );
    return false;
    }
    }
    add_filter('pre_comment_approved', 'sbl', 1);

  2. Bad Behavior does what you're looking for. You may want to either dissect the code or use it instead:

    http://wordpress.org/extend/plugins/bad-behavior/

  3. rtcunningham
    Member
    Posted 4 years ago #

    Bad behavior behaves badly. How's that for a twist? It blocks people it shouldn't. I know, because I tested it for a day.

    I hate dissecting plugins. I usually find the answer isn't there.

  4. rtcunningham
    Member
    Posted 4 years ago #

    I recently wrote a custom script to drop the IP addresses and ranges via an include to wp-config.php. I would much rather have a real blacklist for comments vs. one that marks them as spam. I've search through WordPress support posts going back as far as 2005 and this is really something that people want.

    I just wish I knew how - I tried to make a plugin, but it failed to work as intended.

Topic Closed

This topic has been closed to new replies.

About this Topic