bp_forums_total_topic_count_for_user

Get a total "Topics Started" count for a given user.

Description

(int) bp_forums_total_topic_count_for_user( (int) $user_id = 0, (string) $type = 'active' ); 

Returns (int)

$count The topic count.

Parameters (2)

0. $user_id — Optional. (int)
ID of the user being queried. Falls back on displayed user, then loggedin.
1. $type — Optional. (string) => 'active'
The current filter/sort type. active,, popular., unreplied.

Usage

  1. if ( !function_exists( 'bp_forums_total_topic_count_for_user' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bp-forums-functions.php'; 
  3.  
  4. // ID of the user being queried. Falls back on displayed 
  5. // user, then loggedin. 
  6. $user_id = -1; 
  7.  
  8. // The current filter/sort type. 'active', 'popular', 
  9. // 'unreplied'. 
  10. $type = 'active'; 
  11.  
  12. // NOTICE! Understand what this does before running. 
  13. $result = bp_forums_total_topic_count_for_user($user_id, $type); 
  14.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bp-forums-functions.php  
  1. function bp_forums_total_topic_count_for_user( $user_id = 0, $type = 'active' ) { 
  2.  
  3. /** This action is documented in bp-forums/bp-forums-screens.php */ 
  4.  
  5. if ( !$user_id ) 
  6.  
  7. if ( class_exists( 'BB_Query' ) ) { 
  8. $args = array( 
  9. 'topic_author_id' => $user_id,  
  10. 'page' => 1,  
  11. 'per_page' => -1,  
  12. 'count' => true 
  13. ); 
  14.  
  15. if ( 'unreplied' == $type ) 
  16. $args['post_count'] = 1; 
  17.  
  18. $query = new BB_Query( 'topic', $args ); 
  19. $count = $query->count; 
  20. $query = null; 
  21. } else { 
  22. $count = 0; 
  23.  
  24. return $count;