[Resolved] Hiding self in members directory displays admins
-
I am trying to hide the currently logged in members as well as admins from the members directory/search results. I’m using the following code, but everything I try and hide the currently logged in user (
$excluded_self=bp_loggedin_user_id();
), the admins reappear; commenting out the aforementioned line hides the admins. Does anyone know why that is and how to fix it?//hide all subscribers and admins from search results area add_action('bp_ajax_querystring','bpdev_exclude_users',20,2); function bpdev_exclude_users($qs=false,$object=false){ //list of users to exclude if($object!='members')//hide for members only return $qs; $excluded_user = implode(',',get_users('role=subscriber&fields=ID')); $excluded_admins = implode(',',get_users('role=administrator&fields=ID')); //$excluded_self=bp_loggedin_user_id(); $args=wp_parse_args($qs); //check if we are searching for friends list etc?, do not exclude in this case if(!empty($args['user_id'])) return $qs; if(!empty($args['exclude'])){ $args['exclude']=$args['exclude'].','.$excluded_user; $args['exclude']=$args['exclude'].','.$excluded_admins; //$args['exclude']=$args['exclude'].','.$excluded_self; } else { $args['exclude']=$excluded_user; $args['exclude']=$excluded_admins; //$args['exclude']=$excluded_self; } $qs=build_query($args); return $qs; }
A different issue: the number of resulting members returned when a user searches still includes admins/removed users&roles. Is there a way to fix the results count to exclude those? Can I modify the code below for that?
function bpfr_hide_get_total_filter($count){ return $count-1; } add_filter('bp_get_total_member_count','bpfr_hide_get_total_filter');
- The topic ‘[Resolved] Hiding self in members directory displays admins’ is closed to new replies.