bp_friends_filter_media_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

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function bp_friends_filter_media_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 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 ( ! bp_is_profile_media_support_enabled() ) {
        $friends = array( 0 );
    }
 
    $retval = array(
        'relation' => 'AND',
        array(
            'column'  => 'user_id',
            'compare' => 'IN',
            'value'   => (array) $friends,
        ),
        array(
            'column' => 'privacy',
            'value'  => 'friends',
        ),
    );
 
    if ( ! bp_is_profile_albums_support_enabled() ) {
        $retval[] = array(
            'column'  => 'album_id',
            'compare' => '=',
            'value'   => '0',
        );
    }
 
    if ( ! empty( $filter['search_terms'] ) ) {
        $retval[] = array(
            'column'  => 'title',
            'compare' => 'LIKE',
            'value'   => $filter['search_terms'],
        );
    }
 
    return $retval;
}

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.