bbp_get_user_topic_count_raw

Return the raw database count of topics by a user.

Description

(int) bbp_get_user_topic_count_raw( (int) $user_id = 0 ); 

Returns (int)

Raw DB count of topics

Parameters (1)

0. $user_id — Optional. (int)
The user id.

Usage

  1. if ( !function_exists( 'bbp_get_user_topic_count_raw' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/users/functions.php'; 
  3.  
  4. // The user id. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_user_topic_count_raw($user_id); 
  9.  

Defined (1)

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

/includes/users/functions.php  
  1. function bbp_get_user_topic_count_raw( $user_id = 0 ) { 
  2. $user_id = bbp_get_user_id( $user_id ); 
  3. if ( empty( $user_id ) ) 
  4. return false; 
  5.  
  6. global $wpdb; 
  7.  
  8. $where = get_posts_by_author_sql( bbp_get_topic_post_type(), true, $user_id ); 
  9. $count = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} {$where}" ); 
  10.  
  11. return (int) apply_filters( 'bbp_get_user_topic_count_raw', $count, $user_id );