wordpress自动删除重复评论方法
发布:smiling 来源: PHP粉丝网 添加日期:2015-03-24 16:06:24 浏览: 评论:0
wordpress中,已经默认加入了重复评论的限制,如果需要去掉这个限制,需要修改相应的源代码,具体如下.
wp-includes 文件夹下面 comment.php:
- function wp_allow_comment($commentdata) {
- global $wpdb;
- extract($commentdata, EXTR_SKIP);
- // Simple duplicate check
- // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
- $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved != 'trash' AND ( comment_author = '$comment_author' ";
- if ( $comment_author_email )
- $dupe .= "OR comment_author_email = '$comment_author_email' ";
- $dupe .= ") AND comment_content = '$comment_content' LIMIT 1";
- // if ( $wpdb->get_var($dupe) ) {
- // do_action( 'comment_duplicate_trigger', $commentdata );
- // if ( defined('DOING_AJAX') )
- // die( __('Duplicate comment detected; it looks as though you’ve already said that!') );
- // wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') );
- // }
- do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt );
- if ( isset($user_id) && $user_id) {
- $userdata = get_userdata($user_id);
- $user = new WP_User($user_id);
- $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $comment_post_ID));
- }
- if ( isset($userdata) && ( $user_id == $post_author || $user->has_cap('moderate_comments') ) ) {
- // The author and the admins get respect.
- $approved = 1;
- } else {
- // Everyone else's comments will be checked.
- if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) )
- $approved = 1;//开源软件:phpfensi.com
- else
- $approved = 0;
- if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )
- $approved = 'spam';
- }
- $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata );
- return $approved;
- }
去掉下面部分即可:
- // if ( $wpdb->get_var($dupe) ) {
- // do_action( 'comment_duplicate_trigger', $commentdata );
- // if ( defined('DOING_AJAX') )
- // die( __('Duplicate comment detected; it looks as though you’ve already said that!') );
- // wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') );
- // }
PS:修改前先记得备份哦.
Tags: wordpress重复评论 删除评论
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)