Skip to content

Instantly share code, notes, and snippets.

@quangbahoa
Created January 8, 2014 07:31
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 quangbahoa/8313082 to your computer and use it in GitHub Desktop.
Save quangbahoa/8313082 to your computer and use it in GitHub Desktop.
add_filter( 'preprocess_comment', 'minimal_comment_length' );
function minimal_comment_length( $commentdata ) {
$minimalCommentLength = 20;
if ( strlen( trim( $commentdata['comment_content'] ) ) < $minimalCommentLength ){
wp_die( 'All comments must be at least ' . $minimalCommentLength . ' characters long.' );
}
return $commentdata;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment