在wordpress中,已经默认加入了重复评论的限制,如果需要去掉这个限制,需要修改相应的源代码,具体如下:
&网
wp-includes 文件夹下面 comment.PHP veryhuo.com
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' "; veryhuo.com
$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_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;
veryhuo.com
} else {
// Everyone else's comments will be checked.
if ( check_comment($comment_author,$comment_author_url,$comment_content,$comment_agent,$comment_type) )
$approved = 1;
else
$approved = 0;
if ( wp_blackList_check($comment_author,$comment_agent) )
$approved = 'spam';
}
$approved = apply_filters( 'pre_comment_approved',$approved,$commentdata );
return $approved;
}
去掉下面部分即可 lIEhuo.net
// 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!') );
// } 总结
以上是内存溢出为你收集整理的Wordpress 去掉重复评论限制的办法全部内容,希望文章能够帮你解决Wordpress 去掉重复评论限制的办法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)