BP_Members_Admin::users_table_filter_by_type( WP_Query $query )
Filter WP Admin users list table to include users of the specified type.
Description
Parameters
- $query
-
(Required)
Source
File: bp-members/classes/class-bp-members-admin.php
public function users_table_filter_by_type( $query ) { global $pagenow; if ( is_admin() && 'users.php' === $pagenow && ! empty( $_REQUEST['bp-member-type'] ) ) { $type_slug = sanitize_text_field( $_REQUEST['bp-member-type'] ); // Check that the type is registered. if ( null == bp_get_member_type_object( $type_slug ) ) { return; } // Get the list of users that are assigned to this profile type. $type = bp_get_term_by( 'slug', $type_slug, bp_get_member_type_tax_name() ); if ( empty( $type->term_id ) ) { return; } $user_ids = bp_get_objects_in_term( $type->term_id, bp_get_member_type_tax_name() ); if ( $user_ids && ! is_wp_error( $user_ids ) ) { $query->set( 'include', (array) $user_ids ); } } }
Changelog
Version | Description |
---|---|
BuddyPress 2.7.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.