Eliminate Comment Spam - Blogging for Beginners learn Seo online free step by step

Eliminate Comment Spam

Every blogger knows that comment spam is such a pain. Akismet is good solution, but not always. Why not to block spammers, instead of mark them as spam or suspicious as a spam. The code below looks for HTTP reffere in the request header and blocks the comments if the reffer is wrong or not defined.

Insert the following code in functions.php file of current theme:

function check_referrer() {
    if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == "") {
        wp_die( __('Please enable referrers in your browser, or, if you\'re a spammer, get lost!') );
    }
}
 
add_action('check_comment_flood', 'check_referrer');
 

Explanation.

The code rejects any comment request posting from a browser that has no reffer. Usually it is a bot. The code checks the for ‘HTTP_REFERRE’. If it’s not defined or incorrect, the execution is stopped with the appropriate message.

Enjoy!

Tags: eliminate comment spam, eliminate spam, eliminate spam comment, eliminate wordpress comment spam

 

 

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.