コード例 #1
0
/**
 * Output a comma-separated list of user_ids for a given user's followers.
 *
 * @param array $args See bp_get_follower_ids().
 */
function bp_follower_ids($args = '')
{
    echo bp_get_follower_ids($args);
}
コード例 #2
0
/**
 * Filter the members loop on a follow page.
 *
 * This is done so we can return the users that:
 *   - the current user is following (on a user page or member directory); or
 *   - are following the displayed user on the displayed user's followers page
 *
 * @author r-a-y
 * @since 1.2
 *
 * @param array|string $qs The querystring for the BP loop
 * @param str $object The current object for the querystring
 * @return array|string Modified querystring
 */
function bp_follow_add_member_scope_filter($qs, $object)
{
    // not on the members object? stop now!
    if ($object != 'members') {
        return $qs;
    }
    $set = false;
    // members directory
    // can't use bp_is_members_directory() yet since that's a BP 2.0 function
    if (!bp_is_user() && bp_is_members_component()) {
        // check if members scope is following before manipulating
        if (isset($_COOKIE['bp-members-scope']) && 'following' === $_COOKIE['bp-members-scope']) {
            $set = true;
            $action = 'following';
        }
        // user page
    } elseif (bp_is_user()) {
        $set = true;
        $action = bp_current_action();
    }
    // not on a user page? stop now!
    if (!$set) {
        return $qs;
    }
    // filter the members loop based on the current page
    switch ($action) {
        case 'following':
            // parse querystring into an array
            $qs = wp_parse_args($qs);
            $qs['include'] = bp_get_following_ids(array('user_id' => bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id()));
            $qs['per_page'] = apply_filters('bp_follow_per_page', 20);
            return $qs;
            break;
        case 'followers':
            // parse querystring into an array
            $qs = wp_parse_args($qs);
            $qs['include'] = bp_get_follower_ids();
            $qs['per_page'] = apply_filters('bp_follow_per_page', 20);
            return $qs;
            break;
        default:
            return $qs;
            break;
    }
}
コード例 #3
0
/**
 * Filter the members loop on a user's "Following" or "Followers" page.
 *
 * This is done so we can return the users that:
 *   - the current user is following; or
 *   - the users that are following the current user
 *
 * @author r-a-y
 * @since 1.2
 *
 * @param str $qs The querystring for the BP loop
 * @param str $object The current object for the querystring
 * @return str Modified querystring
 */
function bp_follow_add_member_scope_filter($qs, $object)
{
    // not on the members object? stop now!
    if ($object != 'members') {
        return $qs;
    }
    // not on a user page? stop now!
    if (!bp_is_user()) {
        return $qs;
    }
    // filter the members loop based on the current page
    switch (bp_current_action()) {
        // 'following' page
        case constant('BP_FOLLOWING_SLUG'):
            $args = array('include' => bp_get_following_ids(), 'per_page' => apply_filters('bp_follow_per_page', 20));
            // make sure we add a separator if we have an existing querystring
            if (!empty($qs)) {
                $qs .= '&';
            }
            // add our follow parameters to the end of the querystring
            $qs .= build_query($args);
            return $qs;
            break;
            // 'followers' page
        // 'followers' page
        case constant('BP_FOLLOWERS_SLUG'):
            $args = array('include' => bp_get_follower_ids(), 'per_page' => apply_filters('bp_follow_per_page', 20));
            // make sure we add a separator if we have an existing querystring
            if (!empty($qs)) {
                $qs .= '&';
            }
            // add our follow parameters to the end of the querystring
            $qs .= build_query($args);
            return $qs;
            break;
        default:
            return $qs;
            break;
    }
}