PHP+WORDPRESS

to Require minimum comment length – 曹鹏PHP+WP

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

?>

Leave a Reply

学习的梦想

锤炼的彩色