bp_friends_filter_document_scope( array $retval = array(), array $filter = array() )

Set up media arguments for use with the ‘friends’ scope.

Description

For details on the syntax, see BP_Media_Query.

Parameters

$retval

(Optional) Empty array by default.

Default value: array()

$filter

(Optional) Current activity arguments.

Default value: array()

Return

(array)

Source

File: bp-friends/bp-friends-filters.php

130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
function bp_friends_filter_document_scope( $retval = array(), $filter = array() ) {
 
    // Determine the user_id.
    if ( ! empty( $filter['user_id'] ) ) {
        $user_id = $filter['user_id'];
    } else {
        $user_id = bp_displayed_user_id()
            ? bp_displayed_user_id()
            : bp_loggedin_user_id();
    }
 
    $folder_id = 0;
    $folders   = array();
    if ( ! empty( $filter['folder_id'] ) ) {
        $folder_id = (int) $filter['folder_id'];
    }
 
    // Determine friends of user.
    $friends = friends_get_friend_user_ids( $user_id );
    if ( empty( $friends ) ) {
        $friends = array( 0 );
    }
 
    if ( $user_id !== bp_loggedin_user_id() ) {
        array_push( $friends, bp_loggedin_user_id() );
    }
 
    if ( ! empty( $filter['search_terms'] ) ) {
        if ( ! empty( $folder_id ) ) {
            $folder_ids           = array();
            $user_root_folder_ids = bp_document_get_folder_children( (int) $folder_id );
            if ( $user_root_folder_ids ) {
                foreach ( $user_root_folder_ids as $single_folder ) {
                    $single_folder_ids = bp_document_get_folder_children( (int) $single_folder );
                    if ( $single_folder_ids ) {
                        array_merge( $folder_ids, $single_folder_ids );
                    }
                    array_push( $folder_ids, $single_folder );
                }
            }
            $folder_ids[] = $folder_id;
            $folders      = array(
                'column'  => 'parent',
                'compare' => 'IN',
                'value'   => $folder_ids,
            );
        }
    } else {
        $folders = array(
            'column' => 'folder_id',
            'value'  => 0,
        );
    }
 
    if ( ! bp_is_profile_document_support_enabled() ) {
        $friends = array( 0 );
    }
 
    $args = array(
        'relation' => 'AND',
        array(
            'column'  => 'user_id',
            'compare' => 'IN',
            'value'   => (array) $friends,
        ),
        array(
            'column' => 'privacy',
            'value'  => 'friends',
        ),
        $folders,
    );
 
    return $args;
}

Changelog

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