Index: /sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/bbpress/user-profile.php =================================================================== --- /sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/bbpress/user-profile.php (revision 5628) +++ /sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/bbpress/user-profile.php (revision 5629) @@ -116,8 +116,6 @@
@@ -129,5 +127,5 @@ Index: /sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php =================================================================== --- /sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php (revision 5628) +++ /sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php (revision 5629) @@ -215,4 +215,38 @@ /** + * Return the raw database count of topics by a user, excluding reviews. + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $user_id User ID to get count for. + * @return int Raw DB count of topics. + */ +function wporg_support_get_user_topics_count( $user_id = 0 ) { + global $wpdb; + + $user_id = bbp_get_user_id( $user_id ); + if ( empty( $user_id ) ) { + return 0; + } + + if ( ! class_exists( 'WordPressdotorg\Forums\Plugin' ) ) { + return 0; + } + + $count = (int) $wpdb->get_var( $wpdb->prepare( + "SELECT COUNT(*) + FROM {$wpdb->posts} + WHERE post_type = 'topic' + AND post_status IN ( 'publish', 'closed' ) + AND post_parent <> %d + AND post_author = %d", + WordPressdotorg\Forums\Plugin::REVIEWS_FORUM_ID, + $user_id + ) ); + + return $count; +} + +/** * Return the raw database count of reviews by a user. * @@ -222,5 +256,5 @@ * @return int Raw DB count of reviews. */ -function wporg_support_get_user_review_count( $user_id = 0 ) { +function wporg_support_get_user_reviews_count( $user_id = 0 ) { global $wpdb;