bp_follow_visibility_activity

The BuddyPress Activity Privacy bp follow visibility activity function.

Description

bp_follow_visibility_activity( $remove_from_stream, $visibility, $activity ); 

Parameters (3)

0. $remove_from_stream
The remove from stream.
1. $visibility
The visibility.
2. $activity
The activity.

Usage

  1. if ( !function_exists( 'bp_follow_visibility_activity' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-activity-privacy/includes/bp-activity-privacy-integrations.php'; 
  3.  
  4. // The remove from stream. 
  5. $remove_from_stream = null; 
  6.  
  7. // The visibility. 
  8. $visibility = null; 
  9.  
  10. // The activity. 
  11. $activity = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bp_follow_visibility_activity($remove_from_stream, $visibility, $activity); 
  15.  

Defined (1)

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

/includes/bp-activity-privacy-integrations.php  
  1. function bp_follow_visibility_activity($remove_from_stream, $visibility, $activity) { 
  2. $bp_loggedin_user_id = bp_loggedin_user_id(); 
  3.  
  4. switch ($visibility) { 
  5. case 'followers': 
  6. $args = array( 
  7. 'leader_id' => $activity->user_id,  
  8. 'follower_id' => $bp_loggedin_user_id 
  9. ); 
  10. $is_following = bp_follow_is_following($args); 
  11.  
  12. if( !$is_following )  
  13. $remove_from_stream = true; 
  14. break; 
  15. case 'groupfollowers' : 
  16. $args = array( 
  17. 'leader_id' => $activity->user_id,  
  18. 'follower_id' => $bp_loggedin_user_id 
  19. ); 
  20. $is_following = bp_follow_is_following($args); 
  21.  
  22. $group_is_user_member = groups_is_user_member( $bp_loggedin_user_id, $activity->item_id ); 
  23.  
  24. if( !$is_following || !$group_is_user_member) 
  25. $remove_from_stream = true; 
  26.  
  27. # code... 
  28. default: 
  29. # code... 
  30. break; 
  31. }  
  32.  
  33.  
  34.  
  35. return $remove_from_stream;