SHARE
TWEET

Limit WordPress Comments Length

yeahhub Jun 16th, 2018 24 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * Limit Comment Lenghts (Powered by Yeahhub.com)
  3. */
  4. add_filter( 'preprocess_comment', 'wpb_preprocess_comment' );
  5.  
  6. function wpb_preprocess_comment($comment) {
  7.     if ( strlen( $comment['comment_content'] ) > 5000 ) {
  8.         wp_die('Comment is too long. Please keep your comment under 5000 characters.');
  9.     }
  10. if ( strlen( $comment['comment_content'] ) < 60 ) {
  11.         wp_die('Comment is too short. Please use at least 60 characters.');
  12.     }
  13.     return $comment;
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top