Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Exclude Logged BuddyPress User's member type from the member lists
/**
* Filter members list for logged in user's member type.
*
* @param array $args member query args.
*
* @return array
*/
function buddydev_filter_members_list_exclude_logged_member_type( $args ) {
if ( ! is_user_logged_in() || is_super_admin() ) {
return $args;
}
$member_type = bp_get_member_type( get_current_user_id(), true );
if ( $member_type ) {
$args['member_type__not_in'] = $member_type;
}
return $args;
}
add_filter( 'bp_after_has_members_parse_args', 'buddydev_filter_members_list_exclude_logged_member_type' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.