Require a minimum length for your WordPress comments form

Enabling comments on you WordPress blog may be beneficial for your website. It enables your readers to publish their opinions and exchange ideas. However, a lot of readers tend to leave one word or two words comments. Obviously, these are not the type of comments you would like to get for your posts.

php
add_filter( 'preprocess_comment', 'wph_limit_comment_length' );

function wph_limit_comment_length( $commentdata ) {
   
    $min_Comment_Length = 40;
    $max_Comment_Length = 4000;
   
    if ( strlen( trim( $commentdata['comment_content'] ) ) < $min_Comment_Length ){
    	wp_die( 'You comment is too short! Comments must be at least ' . $min_Comment_Length . ' characters long.' );
    }
    
    if ( strlen( trim( $commentdata['comment_content'] ) ) > $max_Comment_Length ){
    	wp_die( 'You comment is too long! Comments must be under ' . $max_Comment_Length . ' characters long.' );
    }
    
    return $commentdata;
}

You are receiving a lot of short spam comments just give the snippet above a try and see it for yourself a let me know if it works for you. In case you use a different method to require a minimum length for comments form do not hesitate to share.