I've been asked to help out a friend on a site he's cobbled together. I'm unfamiliar with Buddypress but on the members list page it's showing the site admin users, he'd like to exclude them but there are no plugin options to hide them.
I've had this Working to exclude one of them, but I now need to modify it to accept multiple user IDs.
Here's the current code.
add_action( 'bp_ajax_querystring', 'user_remove_mem_directory', 20, 2 );
function user_remove_mem_directory( $query, $object ) {
if ( 'members' != $object ){
return $query;
}
$excluded_user = '93'; // admin id to remove from the member directory
$args = wp_parse_args( $query );
if ( ! empty( $args['exclude'] ) ) {
$args['exclude'] = $args['exclude'] . ',' . $excluded_user;
} else {
$args['exclude'] = $excluded_user;
}
$query = build_query( $args );
return $query;
}
Any help would be much appreciated.
You could make an array of ids like $ids_to_exclude = array('93',...)
then loop through it using a forloop
or while
loop
$ids_to_exclude = array('93',...);
foreach ($ids_to_exclude as &$id) {
function_to_call_on_each_id($id);
}
The PHP manual has really good examples and is super easy to follow. PHP Foreach