这是工作版本,我引用了@Bainternet的技术来完成它。只需更换<?php comment_form(); ?>
使用此代码
<?php
global $wpdb,$current_user;
$limit = 5; //this is limit per day per user
$comment_count = $wpdb->get_var( $wpdb->prepare("
SELECT count(*)
FROM wp_comments
WHERE comment_author = \'%s\'
AND comment_date >= DATE_SUB(NOW(),INTERVAL 1 DAY);"
,$current_user->user_login) );
if($comment_count < $limit) {
comment_form();
}
else {
echo \'exceeded comments limit - \'.$limit;
}
?>
在Wordpress 3.4.1上测试,在上安装了二十个主题
注-
- 只需对当天评论超过5条的用户隐藏评论表单
Regardless of comment status
除非我们从-em>Discussion Settings