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

Set up activity arguments for use with the ‘groups’ scope.

Description

Parameters

$retval

(Optional) Empty array by default.

Default value: array()

$filter

(Optional) Current activity arguments.

Default value: array()

Return

(array)

Source

File: bp-groups/bp-groups-activity.php

306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
function bp_groups_filter_activity_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();
    }
 
    // Determine groups of user.
    $groups = groups_get_user_groups( $user_id );
    if ( empty( $groups['groups'] ) ) {
        $groups = array( 'groups' => 0 );
    }
 
    // Should we show all items regardless of sitewide visibility?
    $show_hidden = array();
    if ( ! empty( $user_id ) && ( $user_id !== bp_loggedin_user_id() ) ) {
        $show_hidden = array(
            'column' => 'hide_sitewide',
            'value'  => 0
        );
    }
 
    $retval = array(
        'relation' => 'AND',
        array(
            'relation' => 'AND',
            array(
                'column' => 'component',
                'value'  => buddypress()->groups->id
            ),
            array(
                'column'  => 'item_id',
                'compare' => 'IN',
                'value'   => (array) $groups['groups']
            ),
        ),
        $show_hidden,
 
        // Overrides.
        'override' => array(
            'filter'      => array( 'user_id' => 0 ),
            'show_hidden' => true
        ),
    );
 
    return $retval;
}

Changelog

Changelog
Version Description
BuddyPress 2.2.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.