Created
July 15, 2015 07:21
-
-
Save lmm214/890086e50a1d597d1c2a to your computer and use it in GitHub Desktop.
Limit Comment Length Using Code Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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