Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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