bp_media_query_privacy( int $user_id, int $group_id, string $scope = '' )

Get list of privacy based on user and group.

Description

Parameters

$user_id

(Required) User ID.

$group_id

(Required) Group ID.

$scope

(Optional) Scope query parameter.

Default value: ''

Return

(mixed|void)

Source

File: bp-media/bp-media-functions.php

2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
function bp_media_query_privacy( $user_id = 0, $group_id = 0, $scope = '' ) {
 
    $privacy = array( 'public' );
 
    if ( is_user_logged_in() ) {
        // User filtering.
        $user_id = (int) (
        empty( $user_id )
            ? ( bp_displayed_user_id() ? bp_displayed_user_id() : false )
            : $user_id
        );
 
        $privacy[] = 'loggedin';
 
        if ( bp_is_my_profile() || $user_id === bp_loggedin_user_id() ) {
            $privacy[] = 'onlyme';
 
            if ( bp_is_active( 'friends' ) ) {
                $privacy[] = 'friends';
            }
        }
 
        if ( ! in_array( 'friends', $privacy ) && bp_is_active( 'friends' ) ) {
 
            // get the login user id.
            $current_user_id = bp_loggedin_user_id();
 
            // check if the login user is friends of the display user
            $is_friend = friends_check_friendship( $current_user_id, $user_id );
 
            /**
             * check if the login user is friends of the display user
             * OR check if the login user and the display user is the same
             */
            if ( $is_friend ) {
                $privacy[] = 'friends';
            }
        }
    }
 
    if (
        bp_is_group()
        || ( bp_is_active( 'groups' ) && ! empty( $group_id ) )
        || ( !empty( $scope ) && 'groups' === $scope )
    ) {
        $privacy = array( 'grouponly' );
    }
 
    return apply_filters( 'bp_media_query_privacy', $privacy, $user_id, $group_id, $scope );
}

Changelog

Changelog
Version Description
BuddyBoss 1.4.0 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.