Require Minimum Comment Length

Paste this code into your WordPress functions.php file to require a minimum comment length. Adjust the ’20’ to set the required characters.

/**
 * Snippet Name: Require Minimum Comment Length
 * Snippet URL: https://www.wpcustoms.net/snippets/require-minimum-comment-length/
 */
  add_filter( 'preprocess_comment', 'minimal_comment_length' );
function minimal_comment_length( $commentdata ) {
    $minimalCommentLength = 20;
    if ( strlen( trim( $commentdata['comment_content'] ) )

 

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x