Support » Plugins » Allow duplicate comment?

  • I need to add the condition “except if duplicate comment_text == ‘no comments’ ” to the duplicate comment validation.

    I’m a copy-paste dev and I’m not sql-code diver yet. I can see the code below is in charge of that, but can’t tell where.

    Can you help me up? (translating the sql would be a plus and would make you my god, hehe)

    $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) ) {
    		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!') );*/

Viewing 1 replies (of 1 total)
  • Sergio,

    You can use this code I just wrote as a starting point:

    My code at that link works by adding some random text to the end of a new comment so it doesn’t look like a dupe. Then that text gets removed from the comment after posting.

    You can add a conditional to the first function to only add the random code when the comment body is “no comment”.


    if($comment_data['comment_content'] == "no comment")
    //add some random content to comment to keep dupe checker from finding it
    $random = md5(time());
    $comment_data['comment_content'] .= "disabledupes{" . $random . "}disabledupes";	
    return $comment_data;

    You need to use all the code from the link above, but add a conditional like this here. I hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Allow duplicate comment?’ is closed to new replies.