bp_blogs_get_profile_stats

Return the number of blogs in user's profile.

Description

(string) bp_blogs_get_profile_stats( (string) $args = '' ); 

Returns (string)

HTML for stats output.

Parameters (1)

0. $args — Optional. (string) => ''
Before|after|user_id.

Usage

  1. if ( !function_exists( 'bp_blogs_get_profile_stats' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-template.php'; 
  3.  
  4. // Before|after|user_id. 
  5. $args = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_blogs_get_profile_stats($args); 
  9.  

Defined (1)

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

/bp-blogs/bp-blogs-template.php  
  1. function bp_blogs_get_profile_stats( $args = '' ) { 
  2.  
  3. // Parse the args. 
  4. $r = bp_parse_args( $args, array( 
  5. 'before' => '<li class="bp-blogs-profile-stats">',  
  6. 'after' => '</li>',  
  7. 'user_id' => bp_displayed_user_id(),  
  8. 'blogs' => 0,  
  9. 'output' => '' 
  10. ), 'blogs_get_profile_stats' ); 
  11.  
  12. // Allow completely overloaded output. 
  13. if ( is_multisite() && empty( $r['output'] ) ) { 
  14.  
  15. // Only proceed if a user ID was passed. 
  16. if ( ! empty( $r['user_id'] ) ) { 
  17.  
  18. // Get the user's blogs. 
  19. if ( empty( $r['blogs'] ) ) { 
  20. $r['blogs'] = absint( bp_blogs_total_blogs_for_user( $r['user_id'] ) ); 
  21.  
  22. // If blogs exist, show some formatted output. 
  23. $r['output'] = $r['before'] . sprintf( _n( '%s site', '%s sites', $r['blogs'], buddypress ), '<strong>' . $r['blogs'] . '</strong>' ) . $r['after']; 
  24.  
  25. /** 
  26. * Filters the number of blogs in user's profile. 
  27. * @since 2.0.0 
  28. * @param string $value Output determined for the profile stats. 
  29. * @param array $r Array of arguments used for default output if none provided. 
  30. */ 
  31. return apply_filters( 'bp_blogs_get_profile_stats', $r['output'], $r );