Replies
Viewing 2 posts - 1 through 2 (of 2 total)
In case it helps someone else:
For the time being, I added a WP role “Community Member”, linked it to the membership purchase, then added this code to functions so the directory only shows users with this role:/** * Exclude Users from BuddyPress Members List unless they have specific WordPress role. * * @param array $args args. * * @return array */ function buddydev_exclude_users_by_role( $args ) { // do not exclude in admin. if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { return $args; } $excluded = isset( $args['exclude'] ) ? $args['exclude'] : array(); if ( ! is_array( $excluded ) ) { $excluded = explode( ',', $excluded ); } $role = 'community_member';// change to the role to be shown. $user_ids = get_users( array( 'role__not_in' => $role, 'fields' => 'ID' ) ); $excluded = array_merge( $excluded, $user_ids ); $args['exclude'] = $excluded; return $args; } add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users_by_role' );
Viewing 2 posts - 1 through 2 (of 2 total)