Buddypress: How to create secondary membersloop?

72 Views Asked by At

I have a list of favorited user ids in PHP. I want to create a secondary membersloop within Buddyboss under a new permalink, e.g.

mypage.com/members/favorited

which only shows the given list of user ids.

The inclusion of only the specific favorited user-ids, I have already implemented as a filter to the membersloop, like so:

function membersloop_show_favorites( $querystring = false, $object = false ) {

    // Only do this for the members loop.
    if ($object != 'members')
        return $querystring;

    // Test Input, comes from database later on ...
    $ids = array(89, 113); // 

    // Make the array a comma sep list.
    $ids = implode( ',', $ids );
    $args = wp_parse_args($querystring);

    if ( ! empty($args['include']) )
        $args['include'] = $args['include'] . ',' . $ids;
    else
        $args['include'] = $ids;

    $querystring = build_query( $args );
    return $querystring;
}
add_action( 'bp_ajax_querystring', 'membersloop_show_favorites', 20, 2 );

The only question is how to make a permalink for that customized membersloop.

0

There are 0 best solutions below