Skip to content

Instantly share code, notes, and snippets.

@Coopeh
Created June 20, 2012 20:29
Show Gist options
  • Save Coopeh/2962023 to your computer and use it in GitHub Desktop.
Save Coopeh/2962023 to your computer and use it in GitHub Desktop.
WordPress Spam Comment HoneyPot
<?php
/*
Plugin Name: Comment HoneyPot
Description: Disallows any comments from users who add a url to the invisible webpage form field
Author: Tim Whitlock - Mods by Ed Cooper
Author URI: http://timwhitlock.info/
Version: 0.1
*/
function _tw_intercept_comment( array $data ){
if( empty($data['comment_author_url']) ){
return $data;
} else {
$message = 'Sorry, we capture spammers who add a web address to the comment form as it\'s hidden. Try writing your comment again without including a web address this time.<br/><br/>If this is an error please let us know at <a href="http://yoursupportsite.com" target="_blank">Your Support Website</a><br/><br/><a onclick="history.go(-1)" style="cursor:pointer;"><strong>Go Back</strong></a>
$title = 'Spam Block';
$args = array('response' => 200);
wp_die( $message, $title, $args );
exit(0);
}
}
add_filter('preprocess_comment','_tw_intercept_comment');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment