bp_blogs_is_blog_trackable

Check whether a given blog should be tracked by the Blogs component.

Description

bp_blogs_is_blog_trackable( (int) $blog_id, (int) $user_id = 0 ); 

If $user_id is provided, the developer can restrict site from being trackable only to particular users.

Parameters (2)

0. $blog_id (int)
ID of the blog being checked.
1. $user_id — Optional. (int)
ID of the user for whom access is being checked.

Usage

  1. if ( !function_exists( 'bp_blogs_is_blog_trackable' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-functions.php'; 
  3.  
  4. // ID of the blog being checked. 
  5. $blog_id = -1; 
  6.  
  7. // Optional. ID of the user for whom access is being checked. 
  8. $user_id = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_blogs_is_blog_trackable($blog_id, $user_id); 
  12.  

Defined (1)

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

/bp-blogs/bp-blogs-functions.php  
  1. function bp_blogs_is_blog_trackable( $blog_id, $user_id = 0 ) { 
  2.  
  3. /** 
  4. * Filters whether or not a blog is globally trackable. 
  5. * @since 1.7.0 
  6. * @param bool $value Whether or not trackable. 
  7. * @param int $blog_id Current blog ID. 
  8. */ 
  9. $trackable_globally = apply_filters( 'bp_blogs_is_blog_trackable', bp_blogs_is_blog_recordable( $blog_id, $user_id ), $blog_id ); 
  10.  
  11. if ( !empty( $user_id ) ) { 
  12.  
  13. /** 
  14. * Filters whether or not a blog is globally trackable for user. 
  15. * @since 1.7.0 
  16. * @param bool $value Whether or not trackable. 
  17. * @param int $blog_id Current blog ID. 
  18. * @param int $user_id Current user ID. 
  19. */ 
  20. $trackable_for_user = apply_filters( 'bp_blogs_is_blog_trackable_for_user', $trackable_globally, $blog_id, $user_id ); 
  21. } else { 
  22. $trackable_for_user = $trackable_globally; 
  23.  
  24. if ( !empty( $trackable_for_user ) ) { 
  25. return $trackable_for_user; 
  26.  
  27. return $trackable_globally;