A Cool Little WordPress Hack To Help Protect Your Blog From Comment Spammers
If you own a WordPress powered website you will most surely have Askimet enabled to help detect and easily manage spammers from posting comments. Askimet is a great plugin that has worked pretty successfully for me on all wordrpess sites that I own or administer. This little wordpress comment hack adds another layer of protection though by looking for the HTTP referrer (the page where the request comes from) and automatically blocks the comment if the referrer is incorrect or not defined.
Paste the code snippet below into your wordpress theme functions.php
1 2 3 4 5 6 7 | 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'); |
This code automatically rejects any request for comment posting coming from a browser (or, more commonly, a bot) that has no referrer in the request. Checking is done with the PHP $_SERVER[] array. If the referrer is not defined or is incorrect, the wp_die function is called and the script stops its execution.
Original Code Snippet thanks to: Yoast.cm
2 Comments › Leave yours
1 Trackbacks
- Top 25 Wordpress Anti Spam Protection And Management Plugins | Stuart Duff - [...] to the RSS feed for updates on this topic.After the post I made a few days back about a ...
Leave a Reply
Search this Site
Stuart on Twitter
- RT @WebDesignDev: ^^ Twitter Tricks And Tips To Get More Followers: http://bit.ly/9xzQcZ ^^
- is watching http://bit.ly/aXBu4W
- is watching http://imdb.to/cKv5D0
- is watching http://bit.ly/bxJpKN
- loved Human Traffic on Boxee http://imdb.to/1FSIzV
Recent Comments
- laiptai on 50 How To Create Design WordPress Themes Web Layouts In Photoshop Tutorials
- Paul on Top 25+ WordPress Anti Spam Protection And Management Plugins
- Daniel on Limit WordPress Posts Text Length Without The Use Of Plugins
- Lola Allen on Are WordPress Premium Themes Becoming Too Heavy and Bloated With PHP Code
- Yan on Limit WordPress Posts Text Length Without The Use Of Plugins




thank you very much…
Copyrighting is very important specially if you wrote original articles both online and offline.;`”