An alternative. Go to cPanel>>file manager>>wp-content>>themes>>theme name>>functions.php file.
Add the code in the file.
Set both minimum and maximum comment length in one code snippets.
1 2 3 4 5 6 7 8 9 10 11 |
add_filter( 'preprocess_comment', 'w3reign_limit_comment' ); function w3reign_limit_comment($comment) { if ( strlen( $comment['comment_content'] ) > 3000 ) { wp_die('Comment is too long. Please keep your comment under 3000 characters.'); } if ( strlen( $comment['comment_content'] ) < 40 ) { wp_die('Comment is too short. Please use at least 40 characters for your comment.'); } return $comment; } |
Set only minimum comment length in WordPress.
1 2 3 4 5 6 7 8 9 10 |
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; } |
[paypal-donation]