bp_blogs_total_blogs_for_user

Get the total number of blogs being tracked by BP for a specific user.

Description

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

Returns (int)

$count Total blog count for the user.

Parameters (1)

0. $user_id — Optional. (int)
ID of the user being queried. Default: on a user page, the displayed user. Otherwise, the logged-in user.

Usage

  1. if ( !function_exists( 'bp_blogs_total_blogs_for_user' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-functions.php'; 
  3.  
  4. // ID of the user being queried. Default: on a user page, 
  5. // the displayed user. Otherwise, the logged-in user. 
  6. $user_id = -1; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_blogs_total_blogs_for_user($user_id); 
  10.  

Defined (1)

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

/bp-blogs/bp-blogs-functions.php  
  1. function bp_blogs_total_blogs_for_user( $user_id = 0 ) { 
  2. if ( empty( $user_id ) ) { 
  3.  
  4. // No user ID? do not attempt to look at cache. 
  5. if ( empty( $user_id ) ) { 
  6. return 0; 
  7.  
  8. $count = wp_cache_get( 'bp_total_blogs_for_user_' . $user_id, 'bp' ); 
  9. if ( false === $count ) { 
  10. $count = BP_Blogs_Blog::total_blog_count_for_user( $user_id ); 
  11. wp_cache_set( 'bp_total_blogs_for_user_' . $user_id, $count, 'bp' ); 
  12.  
  13. return $count;