count number of all comments by a user on different (non-repeated) posts
If you want to count the number of posts the user commented on, you can try: global $wpdb; $sql=”SELECT COUNT( comment_ID ) FROM ” . $wpdb->comments . ‘ WHERE user_id = %d AND comment_approved = “1” AND comment_type NOT IN (“pingback”, “trackback” ) GROUP by comment_post_ID’; $count = $wpdb->get_var( $wpdb->prepare( $sql, $user->ID ) ); where … Read more