Double Wordpress Comment Detection

Does anyone know how to disable duplicate comment detection in Wordpress (2.9.2)? I am looking for a way to do this programmatically without editing core files. We add comments through XMLRPC, and duplicate detection in wp-includes / comment.php (line 494) causes problems during testing.

Thank!

+5
source share
4 answers

There are currently no hooks available for this without editing kernel files.

A better way would be to comment on a duplicate check with wp-includes/comment.php

+3
source

. 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
}
+12
    $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";
0
source

I had the same problem when replying to the backend for comments.

But just the answer with the same comment on the frontend worked perfectly, without changing anything.

Hope this can help someone.

0
source

All Articles