Tagged: hide admins, hide by user ID
I am already using the hide admins code which has been specially customized to work with the paid plugin: BuddyBlock due to past interferences…
My hide admin code is below, but how to also hide any users by ID, while also hiding all admins?:
function pp_filter_members( $query_array ) { $excluded = array(); if ( isset( $query_array->query_vars['exclude'] ) ) { $excluded = $query_array->query_vars['exclude']; } if ( ! is_array( $excluded ) ) { $excluded = explode( ',', $excluded ); } $role = 'administrator'; // change to the role to be excluded. $user_ids = get_users( array( 'role' => $role, 'fields' => 'ID' ) ); $new_excluded = array_merge( $excluded, $user_ids ); $query_array->query_vars['exclude'] = $new_excluded; } add_action( 'bp_pre_user_query_construct', 'pp_filter_members', 99, 1 );
.
Hi Kristian,
Thank you for teh question.Please change this line
$new_excluded = array_merge( $excluded, $user_ids );
to
$other_ids = array( 1,2,3,4,5); //update it with correct ids $new_excluded = array_merge( $excluded, $user_ids, $other_ids );
That should do it.
Regards
BrajeshThank you, Brajesh!
As always, your code works perfectly.
Best,
Kristian
Viewing 4 posts - 1 through 4 (of 4 total)
The topic ‘ [Resolved] hiding users by id, not just admins’ is closed to new replies.
This topic is: resolved