This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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