wordpress自动删除重复评论方法
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;
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:修改前先记得备份哦
创造与魔法 安卓版v1.0.0750
创造与魔法是一款开放世界手游,在游戏中玩家可探索这个奇妙的世
创造与魔法修改版 最新版v1.0.0750
创造与魔法无限点券版是款探索冒险游戏,该款游戏的操作还是蛮自
战争与文明官方版本 安卓版v1.7.16
战争与文明是一款由上海邮通科技有限公司开发的战争策略游戏,这
迷你世界0元领皮肤无限迷你币版 最新安卓版v1.43.0
迷你世界0元购买皮肤版是这款开放沙盒冒险建造游戏的特殊破解版
创造与魔法无限经验版 安卓版v1.0.0750
创造与魔法无限经验版是款可以改造环境,整个游戏的自由度还是蛮