Skip to content

Instantly share code, notes, and snippets.

@cowgill
Created May 16, 2013 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cowgill/5592248 to your computer and use it in GitHub Desktop.
Save cowgill/5592248 to your computer and use it in GitHub Desktop.
Block all WordPress comments that try include a url.
+// check honeypot field when a new comment is submitted
+// we hide the url field from normal visitors via css
+function at_pre_comment_check() {
+
+ if ( ! empty( $_POST['url'] ) )
+ wp_die( "Comment rejected because it triggered our spam filter. Disable any auto form filler and try again." );
+
+}
+add_action( 'pre_comment_on_post', 'at_pre_comment_check' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment