bbp_get_user_post_count

Return a users total post count.

Description

(string) bbp_get_user_post_count( (int) $user_id = 0, (bool) $integer = false ); 

Returns (string)

Parameters (2)

0. $user_id — Optional. (int)
The user id.
1. $integer — Optional. (bool) => false
Whether or not to format the result

Usage

  1. if ( !function_exists( 'bbp_get_user_post_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/users/options.php'; 
  3.  
  4. // The user id. 
  5. $user_id = -1; 
  6.  
  7. // Optional. Whether or not to format the result 
  8. $integer = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_get_user_post_count($user_id, $integer); 
  12.  

Defined (1)

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

/includes/users/options.php  
  1. function bbp_get_user_post_count( $user_id = 0, $integer = false ) { 
  2.  
  3. // Validate user id 
  4. $user_id = bbp_get_user_id( $user_id ); 
  5. if ( empty( $user_id ) ) 
  6. return false; 
  7.  
  8. $topics = bbp_get_user_topic_count( $user_id, true ); 
  9. $replies = bbp_get_user_reply_count( $user_id, true ); 
  10. $count = (int) $topics + $replies; 
  11. $filter = ( true === $integer ) ? 'bbp_get_user_post_count_int' : 'bbp_get_user_post_count'; 
  12.  
  13. return apply_filters( $filter, $count, $user_id );