Skip to content

Instantly share code, notes, and snippets.

@ozh
Created February 23, 2014 18:25
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 ozh/9175184 to your computer and use it in GitHub Desktop.
Save ozh/9175184 to your computer and use it in GitHub Desktop.
WordPress: No comment URL -- or die
<?php
/*
Plugin Name: Ozh' No Comment URL
Plugin URI: http://planetozh.com/
Description: No comment URL or die
Version: 1.0
Author: Ozh
Author URI: http://ozh.org/
*/
add_filter( 'preprocess_comment', 'ozh_ncu_check', -999 );
function ozh_ncu_check( $in ) {
// Don't check logged in users
global $user_ID;
if( isset( $user_ID ) && $user_ID )
return $in;
// Die if comment URL
if( !empty( $in['comment_author_url'] ) ) {
wp_die(
"<h1>Sorry, you don't qualify to comment on this site</h1><p>Go spam somewhere else.</p>",
"Forbidden",
array( 'response' => 403 )
);
die();
}
// So far, so good
return $in;
}

In the theme CSS, something like:

#comment_url {
    display:none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment