After MUCH effort finding scripts and snippets to remove admin and a particular role -I found one – but it ended up causing problems so disabled.
Left without a solution, I found this awesome plugin.
Please suggest it in your docs to help future Gwangi fans like me who want to exclude Admin roles and the like.
PLUS it allows restriction of profile viewing! the only plugin I can find which does so.
BP Custom Functionalities
Under 10 active downloads – not sure how its not been found…
Here’s the snip used in any case:
/**
* Exclude Users from BuddyPress Members List by WordPress role.
*
* @param array $args args.
*
* @return array
*/
function buddydev_exclude_users_by_role( $args ) {
// do not exclude in admin.
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return $args;
}
$excluded = isset( $args['exclude'] ) ? $args['exclude'] : array();
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' ) );
$excluded = array_merge( $excluded, $user_ids );
$args['exclude'] = $excluded;
return $args;
}
add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users_by_role' );