Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress duplicate comment detection

Tags:

wordpress

Does anyone know how to disable duplicate comment detection in Wordpress (2.9.2)? I'm looking for a way to do this programatically without editing core files. We're adding comments via XMLRPC and the duplicate detection in wp-includes/comment.php (line 494) is causing issues during testing.

Thanks!

like image 430
codecowboy Avatar asked May 31 '10 10:05

codecowboy


2 Answers

Actually, you don't need to edit ANY core files to do this. Just put these one filter and two tiny functions in your theme's functions.php file and duplicate comments will no longer be rejected.

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
}
like image 134
hardy101 Avatar answered Sep 21 '22 11:09

hardy101


Currently, there are no hooks available to do this without editing core files.

The best way would be to comment out the duplicate check from wp-includes/comment.php

like image 37
Dogbert Avatar answered Sep 22 '22 11:09

Dogbert