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
- Display AdSense Ads to Search Engines Visitors Only
- Using Normal Quotes Instead of Curly Quotes
- Using CSS Sliding Doors in WordPress Navigaton
- Display a Random Header Image on Your WordPress Blog
- Replacing “Next” and “Previous” Page Links with Pagination