Ron told me the BP function that pulls the list of members is bp_members() … do you know of a filter or hook for this function that would do this?
I see that there is a plugin in development that filters the members loop here: https://buddypress.org/community/groups/third-party-components-plugins/forum/topic/bp-member-filter/?topic_page=3&num=15
If this is the case, couldn’t I simply apply a similar filter to the list to filter it by domain?
Thoughts?
I see several threads on different sites such as this one: https://buddypress.org/community/groups/creating-extending/forum/topic/solved-limit-members-loop-by-profile-fields/
…where people of successfully filtered the member loop by role, but how to filter it by domain / site?
I think I found a solution! But I don’t quite know how to edit the code. According to this page:
https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-members-loop/
you can use THIS parameter on the bp_has_members() function:
user_id optional
Limit the members returned to only friend connections of the logged in user.
Default value: false
….that when people clicked All Members (if I understand this right), it would only show them users which they have FRIENDED and because they can only FRIEND users who they can see activity for, which are members who sign up and join groups on THEIR site, the resulting effect would be a filter for users on other sites, users they can’t see activity for, correct?
Now, how on earth do I use this paramater on this function and what would the resulting code look like? I’m sure that’s an easy one for you guys right?
Would it be something like this:
if ( bp_has_members( 'user_id=0' ) )
UPDATE: i was wrong, this parameter specifies all the friends of a given user ID, so the question now is, how could I use this to dynamically get only the friends of the currently logged in user, whatever that user may be?
UPDATE: I see that this can grab the currenlty logged in user Id: $bp->loggedin_user->id
So how to put the two together?
UPDATE: Why won’t this work?
bp_has_members( $user_id = $bp->loggedin_user->id .
There is also this used by the My Friends:
if ( bp_has_members( ‘include=’ . bp_get_friendship_requests() )
but I tried that in members-loop.php and it didn’t return any members when refreshing the list.
I feel like I’m so close. By the way, the BP Codex page for bp_has_members function is somewhat misleading when specifying this parameter:
user_id optional
Limit the members returned to only friend connections of the logged in user.
Default value: false
That really makes it sound as if when you use this argument, it will only return the friends of the currently logged in user, whoever that may be. Instead, what it really returns is the friends of whoever’s user ID you specify in the parameter. But why would that be useful? It doesn’t make sense to me, why would people ever want to see the friends of another person only when clicking All Members? There’s got to be something I’m missing here. I just want it to show the friends of the currently logged in user.
If the second tab (My Friends) returns only the logged in users friend connections, why can’t I get the first tab (All Members) to return the same exact thing? A better solution for me would even be for the first tab (All Members), members loop to only return members that have activity on the current site (as opposed to displaying members site wide). I think I will try this tomorrow morning:
if ( bp_has_members( ‘type=active’ ))
to see if this is the case.
Any thoughts would be appreciated.
you can also use this:
bp_has_members( ‘meta_key=source_domain&meta_value=domain.com’
to filter member list by domain, but again, i would need a dynamic solution that would automatically GET the source domain for the given site.
sigh- im going to sleep. See ya tomorrow.
Thanks for the feedback about BP multi network support. We’ve not had too many people tell us how well it is working, so glad to see it mostly works for you. I’ll make a bug report about the two issues you specifically raise.
Tried that, didn’t work. I also tried these:
bp_has_members( $meta_key = ‘source_domain’ . $meta_value = $current_site->domain )
bp_has_members( ‘meta_key=source_domain’ . $meta_value = $current_site->domain )
bp_has_members( ‘meta_key=source_domain&meta_value=’ . $current_site->domain )
either didn’t do anything or did not return any results, and it causes the My Friends tab to not return results either.
So I go the other route and try these…
bp_has_members( $user_id = $bp->loggedin_user->id )
bp_has_members( $include = $bp->loggedin_user->id )
bp_has_members( ‘include=’ . $bp->loggedin_user->id )
bp_has_members( ‘user_id=’ . $bp->loggedin_user->id )
the first to don’t do anything and the second two do not return any results, and causes the My Friends tab to not return results either.
bp_has_members( ‘include=’ . bp_get_friendship_requests() . ‘&per_page=0? ) )
which is used in the friends-loop (My Friends tab) does not work when attempting to use it in the members-loop.php (All Members tab) and again causes both tabs to not return results.
The FULL function that my theme uses looks like this:
if ( bp_has_members( ‘meta_key=source_domain&meta_value=’ . $current_site->domain . bp_ajax_querystring( ‘members’ ) ) )
…with that ajax thing at the end, could that be what’s causing these not to work? I did try taking that out and when I do that, the various filters seem to be applying to both tabs, the members-loop and the friends-loop the same. Not sure why.
Thanks
Is there not a way to do this??????????
I just need an answer please.