Skip to content

Instantly share code, notes, and snippets.

@JulioPotier
Created July 25, 2014 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JulioPotier/cd263e84f077266ade3b to your computer and use it in GitHub Desktop.
Save JulioPotier/cd263e84f077266ade3b to your computer and use it in GitHub Desktop.
add_filter( 'preprocess_comment', 'baw_no_double_thread' );
function baw_no_double_thread( $comment )
{
if ( current_user_can( 'administrator' ) ) {
return $comment;
}
global $wpdb;
if ( ! $comment['comment_parent'] ) {
$c = $wpdb->get_var( $wpdb->prepare( 'SELECT comment_ID FROM '.$wpdb->comments.' WHERE comment_post_ID = %d AND comment_author_email = %s AND comment_parent = 0', $comment->comment_post_ID, $comment['comment_author_email'] ) );
if ( (int) $c > 0 ) {
$comment['comment_parent'] = $c;
}
}
return $comment;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment