Created
July 1, 2013 20:28
-
-
Save sbrajesh/5904292 to your computer and use it in GitHub Desktop.
hide admins and subscribers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('bp_ajax_querystring','bpdev_exclude_users',20,2); | |
function bpdev_exclude_users($qs=false,$object=false){ | |
//list of users to exclude | |
$excluded_user=join(',', bpdev_get_subscriber_admin_user_ids());//comma separated ids of users whom you want to exclude | |
if($object!='members')//hide for members only | |
return $qs; | |
$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; | |
else | |
$args['exclude']=$excluded_user; | |
$qs=build_query($args); | |
return $qs; | |
} | |
function bpdev_get_subscriber_admin_user_ids(){ | |
$users=array(); | |
$subscribers= get_users( array( 'role' => 'subscriber' ,'fields'=>'ID') ); | |
$admins= get_users( array( 'role' => 'administrator' ,'fields'=>'ID') ); | |
$users = array_merge($subscribers,$admins); | |
return $users; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I must remember to use the
array_merge()
function