2010-05-31 30 views
5

有誰知道如何禁用Wordpress(2.9.2)中的重複評論檢測?我正在尋找一種編程方式來編輯核心文件。我們通過XMLRPC添加評論,並且wp-includes/comment.php中的重複檢測(第494行)在測試過程中引發問題。WordPress的重複評論檢測

謝謝!

回答

3

目前,在沒有編輯核心文件的情況下,沒有可用的鉤子來做到這一點。

最好的辦法是從wp-includes/comment.php

+0

這意味着如果同一作者在同一帖子上寫多個評論,則認爲它是重複的。這是錯誤的!但謝謝你的回答。 – codecowboy 2010-06-02 13:29:19

0
$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"; 
12

註釋掉重複檢查其實,你不需要編輯任何核心文件做到這一點。只需在主題的functions.php文件中添加這一個過濾器和兩個小功能,重複的評論就不會被拒絕。

add_filter('wp_die_handler', 'my_wp_die_handler_function', 9); //9 means you can unhook the default before it fires 

function my_wp_die_handler_function($function) { 
    return 'my_skip_dupes_function'; //use our "die" handler instead (where we won't die) 
} 

//check to make sure we're only filtering out die requests for the "Duplicate" error we care about 
function my_skip_dupes_function($message, $title, $args) { 
    if (strpos($message, 'Duplicate comment detected') === 0) { //make sure we only prevent death on the $dupe check 
     remove_filter('wp_die_handler', '_default_wp_die_handler'); //don't die 
    } 
    return; //nothing will happen 
} 
+0

警告:這會刪除一些重要的檢查。例如,人們可以評論匿名,雖然不允許通過設置。你可以通過加載帖子,刪除你的cookies然後嘗試發送評論來測試。 – 2015-07-28 09:37:30

+0

有關更優雅的解決方案,請參閱:http://www.strangerstudios.com/blog/2010/10/duplicate-comment-detected-it-looks-as-though-youve-already-said-that/ – 2015-07-28 09:43:38

+0

不工作了。 – tinyCoder 2017-03-01 13:15:48

0

我在評論後端回覆時有同樣的問題。

但只是在前端的相同評論回覆沒有改變任何東西都工作正常。

希望這可能有助於某人。