Remove User from BuddyPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Exclude users from BuddyPress members list. | |
* | |
* @param array $args args. | |
* | |
* @return array | |
*/ | |
function buddydev_exclude_users( $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 ); | |
} | |
// Change it with the actual numeric user ids. | |
$user_ids = array( 13, 24 ); // user ids to exclude. | |
$excluded = array_merge( $excluded, $user_ids ); | |
$args['exclude'] = $excluded; | |
return $args; | |
} | |
add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment