Skip to content

Instantly share code, notes, and snippets.

@cre8tivediva
Created November 8, 2020 23:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cre8tivediva/d69d0c60eef938925cb5f0beee316c6b to your computer and use it in GitHub Desktop.
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