Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove User from BuddyPress
/**
* 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