Skip to content

Instantly share code, notes, and snippets.

@lmm214
Created July 15, 2015 07:21
Show Gist options
  • Save lmm214/890086e50a1d597d1c2a to your computer and use it in GitHub Desktop.
Save lmm214/890086e50a1d597d1c2a to your computer and use it in GitHub Desktop.
Limit Comment Length Using Code Snippet
add_filter( 'preprocess_comment', 'wpb_preprocess_comment' );
function wpb_preprocess_comment($comment) {
if ( strlen( $comment['comment_content'] ) > 5000 ) {
wp_die('Comment is too long. Please keep your comment under 5000 characters.');
}
if ( strlen( $comment['comment_content'] ) < 60 ) {
wp_die('Comment is too short. Please use at least 60 characters.');
}
return $comment;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment