bp_activity_has_media_activity_filter( $has_activities, $activities )
Filter the activities for document and media privacy
Description
Parameters
- $has_activities
-
(Required)
- $activities
-
(Required)
Return
(mixed)
Source
File: bp-activity/bp-activity-filters.php
function bp_activity_has_media_activity_filter( $has_activities, $activities ) { if ( ! $has_activities || ! bp_is_active( 'media' ) || ! bp_is_single_activity() ) { return $has_activities; } if ( ! empty( $activities->activities ) ) { foreach ( $activities->activities as $key => $activity ) { if ( in_array( $activity->privacy, array( 'media', 'document' ) ) ) { $parent_activity_id = false; if ( ! empty( $activity->secondary_item_id ) ) { $parent_activity_id = $activity->secondary_item_id; } else { $attachment_id = BP_Media::get_activity_attachment_id( $activity->id ); if ( ! empty( $attachment_id ) ) { $parent_activity_id = get_post_meta( $attachment_id, 'bp_media_parent_activity_id', true ); } } if ( ! empty( $parent_activity_id ) ) { $parent = new BP_Activity_Activity( $parent_activity_id ); $parent_user = $parent->user_id; $parent_privacy = $parent->privacy; if ( $parent_privacy === 'public' ) { continue; } $remove_from_stream = false; if ( $parent_privacy === 'loggedin' && ! bp_loggedin_user_id() ) { $remove_from_stream = true; } if ( false === $remove_from_stream && $parent_privacy === 'onlyme' && bp_loggedin_user_id() !== $parent_user ) { $remove_from_stream = true; } if ( false === $remove_from_stream && $parent_privacy === 'friends' ) { if ( bp_is_active( 'friends' ) ) { $is_friend = friends_check_friendship( bp_loggedin_user_id(), $parent_user ); if ( ! $is_friend && $parent_user !== bp_loggedin_user_id() ) { $remove_from_stream = true; } } else { $remove_from_stream = true; } } if ( $remove_from_stream && isset( $activities->activity_count ) ) { $activities->activity_count = $activities->activity_count - 1; if ( isset( $activities->total_activity_count ) ) { $activities->total_activity_count = $activities->total_activity_count - 1; } unset( $activities->activities[ $key ] ); } } } } } $activities->activities = array_values( $activities->activities ); if ( $activities->activity_count === 0 ) { return false; } return $has_activities; }
Changelog
Version | Description |
---|---|
BuddyBoss 1.4.3 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.