Skip to content

Instantly share code, notes, and snippets.

@wbcomdev
Last active June 23, 2021 12:59
Show Gist options
  • Select an option

  • Save wbcomdev/f61d9ed10fda984217edb15dd00f58ea to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/f61d9ed10fda984217edb15dd00f58ea to your computer and use it in GitHub Desktop.
<?php
/**
* Hide users from BuddyPress members list.
*
* @param array $args Args.
*
* @return array
*/
function wbcom_exclude_members_from_member_directory_page( $args ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return $args;
}
$excluded = isset( $args['exclude'] ) ? $args['exclude'] : array();
if ( ! is_array( $excluded ) ) {
$excluded = explode( ',', $excluded );
}
$user_ids = array( 20, 24, 32 ); // user ids to exclude.
$excluded = array_merge( $excluded, $user_ids );
$args['exclude'] = $excluded;
return $args;
}
add_filter( 'bp_after_has_members_parse_args', 'wbcom_exclude_members_from_member_directory_page' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment