bp_ap_rtmedia

Check the privacy for each medias and remove the not authorized medias from media array.

Description

bp_ap_rtmedia(); 

Usage

  1. if ( !function_exists( 'bp_ap_rtmedia' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-activity-privacy/includes/bp-activity-privacy-integrations.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_ap_rtmedia(); 
  7.  

Defined (1)

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

/includes/bp-activity-privacy-integrations.php  
  1. function bp_ap_rtmedia() { 
  2. global $rtmedia_query; 
  3. have_rtmedia (); 
  4.  
  5. $is_super_admin = is_super_admin(); 
  6. $bp_displayed_user_id = bp_displayed_user_id(); 
  7. $bp_loggedin_user_id = bp_loggedin_user_id(); 
  8.  
  9. if ( ( !empty($bp_displayed_user_id) && $bp_displayed_user_id == $bp_loggedin_user_id ) || $is_super_admin ) 
  10. return; 
  11.  
  12. $count_removed_media = 0; 
  13. if (!empty($rtmedia_query->media)) { 
  14. foreach ($rtmedia_query->media as $key => $media) { 
  15.  
  16. $activities = bp_activity_get_specific( array( 'activity_ids' => $media->activity_id ) ); 
  17. $activity = $activities["activities"][0]; 
  18.  
  19. $remove_from_stream = bp_visibility_is_activity_invisible( $activity, $bp_loggedin_user_id, $is_super_admin, $bp_displayed_user_id ); 
  20. if ($remove_from_stream) { 
  21. unset($rtmedia_query->media[$key]); 
  22. $count_removed_media++; 
  23. }  
  24. //rearrange array keys 
  25. $rtmedia_query->media = array_values($rtmedia_query->media); 
  26.  
  27. $rtmedia_query->media_count = $rtmedia_query->media_count - $count_removed_media;