Deny Comment Posting to No Referrer Requests
The problem. Spam is a problem for every blogger. Sure, Akismet is there to help, but what about preventing spam just a bit more? The following code will look for the referrer (the URL from where the page was called) when the wp-comments-post.php file is accessed. If a referrer exists, and if it is your blog’s URL, the comment is allowed. Otherwise, the page will stop loading and the comment will not be posted.
The solution. To apply this hack, simply paste the following code into your theme’s function.php file. If your theme doesn’t have this file, just create it.
1 |
function check_referrer() { |
2 |
if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == “”) { |
3 |
wp_die( __('Please enable referrers in your browser, or, if you\'re a spammer, bugger off!') ); |
7 |
add_action('check_comment_flood', 'check_referrer'); |
Source:
Hot Trending Topics
- Rules to speed up your website
- 8 Useful WordPress SQL Hacks