Changeset 6609 for trunk/src/includes/users/functions.php
- Timestamp:
- 07/03/2017 11:22:01 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/functions.php
r6601 r6609 621 621 function bbp_get_user_topic_count_raw( $user_id = 0 ) { 622 622 $user_id = bbp_get_user_id( $user_id ); 623 if ( empty( $user_id ) ) { 624 return false; 625 } 626 627 $count = count_user_posts( $user_id, bbp_get_topic_post_type(), false ); 628 // Manually add the user closed topic count, see #2978 and #WP12706 629 $count = $count + bbp_get_user_closed_topic_count( $user_id ); 623 $bbp_db = bbp_db(); 624 $statii = "'" . implode( "', '", bbp_get_public_topic_statuses() ) . "'"; 625 $sql = "SELECT COUNT(*) 626 FROM {$bbp_db->posts} 627 WHERE post_author = %d 628 AND post_type = %s 629 AND post_status IN ({$statii})"; 630 631 $query = $bbp_db->prepare( $sql, $user_id, bbp_get_topic_post_type() ); 632 $count = (int) $bbp_db->get_var( $query ); 630 633 631 634 // Filter & return … … 644 647 function bbp_get_user_reply_count_raw( $user_id = 0 ) { 645 648 $user_id = bbp_get_user_id( $user_id ); 646 if ( empty( $user_id ) ) { 647 return false; 648 } 649 650 $count = count_user_posts( $user_id, bbp_get_reply_post_type(), false ); 649 $bbp_db = bbp_db(); 650 $sql = "SELECT COUNT(*) 651 FROM {$bbp_db->posts} 652 WHERE post_author = %d 653 AND post_type = %s 654 AND post_status %s"; 655 656 $query = $bbp_db->prepare( $sql, $user_id, bbp_get_reply_post_type(), bbp_get_public_status_id() ); 657 $count = (int) $bbp_db->get_var( $query ); 651 658 652 659 // Filter & return … … 665 672 function bbp_get_user_closed_topic_count( $user_id = 0 ) { 666 673 $user_id = bbp_get_user_id( $user_id ); 667 if ( empty( $user_id ) ) { 668 return false; 669 } 670 671 $bbp_db = bbp_db(); 672 $count = (int) $bbp_db->get_var( $bbp_db->prepare( 674 $bbp_db = bbp_db(); 675 $count = (int) $bbp_db->get_var( $bbp_db->prepare( 673 676 "SELECT COUNT(*) 674 677 FROM {$bbp_db->posts}
Note: See TracChangeset
for help on using the changeset viewer.