我的要求有点不同,我可以用过滤器隐藏电子邮件和网站字段,但我想知道的是,当我发表评论时,有没有一种方法可以使评论文本不需要,而没有注释文本区域填充了它的给我错误,需要评论,请指导我如何使评论文本不需要。
add_action(\'pre_comment_on_post\', \'dump_comment\');
function dump_comment($post_id, $author=null, $email=null) {
$comcnt = $cmntcount = comments_number( \'#0\', \'#1\', \'#%\' );
$comment = ( isset($_POST[\'comment\']) ) ? trim($_POST[\'comment\']) : null;
if (!$comment) {
$_POST[\'comment\'] = \'Design\' . $comcnt;
}
}
更新和工作代码。 add_action(\'pre_comment_on_post\', \'dump_comment\');
function dump_comment($post_id, $author=null, $email=null) {
$comment = ( isset($_POST[\'comment\']) ) ? trim($_POST[\'comment\']) : null;
if (!$comment) {
$_POST[\'comment\'] = \'Design #\' . get_comments_number();
}
}
使评论每次都是独一无二的。通过添加注释计数的值。