Deny comment no referrer requests

Adding this PHP code to the functions.php will check the referrer when a user posts a comment to ensure they are not a BOT. Thanks to Joost de Valk for this little snippet,

 

 

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, bugger off!’) );
}
}
add_action(‘check_comment_flood’, ‘check_referrer’);

Leave a comment