Replies
Viewing 3 posts - 1 through 3 (of 3 total)
Hello Brajesh,
You are the GOAT! I would like to exclude contributor accounts too. Is the below code how you would do it? Sourced from one of your comments on the original blog posts.
/** * Exclude Users from BuddyPress Members List by WordPress role. * * @param array $args args. * * @return array */ function buddydev2_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 ); } $user_ids = get_users( array( 'role__in' => ['administrator' , 'contributor'] ,'fields'=>'ID') ); $excluded = array_merge( $excluded, $user_ids ); $args['exclude'] = $excluded; return $args; } add_filter( 'bp_after_core_get_users_parse_args', 'buddydev2_exclude_users_by_role' );
Viewing 3 posts - 1 through 3 (of 3 total)