BBP_BuddyPress_Activity::activity_forums_scope( array $retval = array(), array $filter = array() )

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

Description

For details on the syntax, see BP_Activity_Query.

Parameters

$retval

(Optional) Empty array by default.

Default value: array()

$filter

(Optional) Current activity arguments.

Default value: array()

Return

(array)

Source

File: bp-forums/activity.php

813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
public function activity_forums_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();
    }
 
    $forum_ids = bbp_get_user_subscribed_forum_ids( $user_id );
    $topic_ids = bbp_get_user_subscribed_topic_ids( $user_id );
 
    if ( empty( $forum_ids ) ) {
        $forum_ids = array( 0 );
    }
 
    if ( empty( $topic_ids ) ) {
        $topic_ids = array( 0 );
    }
 
    $retval = array(
        'relation' => 'AND',
        array(
            'column'  => 'component',
            'compare' => '=',
            'value'   => 'bbpress',
        ),
        array(
            'relation' => 'OR',
            array(
                'column'  => 'secondary_item_id',
                'compare' => 'IN',
                'value'   => (array) $forum_ids,
            ),
            array(
                'column'  => 'secondary_item_id',
                'compare' => 'IN',
                'value'   => (array) $topic_ids,
            ),
        ),
 
        // we should only be able to view sitewide activity content for those the user.
        // is following.
        array(
            'column' => 'hide_sitewide',
            'value'  => 0,
        ),
 
    );
 
    return $retval;
}

Changelog

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