How to Limit Comment Length in WordPress


How to Limit Comment Length in WordPress
Jude Nieves

The plugin is no longer in WordPress directory, but the code works very well. However, I want to know is there a way we can “gray out” or “disable” the submit button if the comment length conditions are not met. Right now, what this code do is it allow the user to submit comment and they get an error message if their comment length is not as per code criteria. By greying out the button we will be able to stop users from getting irritated and their will be no need to hit the back button.

How to Limit Comment Length in WordPress
Debby Brand

WordPress comments encourage discussions around your topic but there may be a few comments with extreme lengths. These may not be helpful to users reading your article. In this video, we will show you how to how to limit comment length in WordPress.

How to Limit Comment Length in WordPress With or Without a Plugin
Beverly Martinez

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;
}

How To Limit Comment Length In WordPress Without Plugin
Bao Mount

Have you ever thought to create a limit for the number of characters in your comment section? It wouldn’t let anyone drop the smaller comments.

Be the first to comment

Leave a Reply

Your email address will not be published.


*