Created
January 21, 2020 19:57
-
-
Save webmasterninjay/de4841cb689d1085bfeb684354d03bab to your computer and use it in GitHub Desktop.
Exclude several user roles from buddypress loop
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
<?php | |
function exclude_roles_from_members_loop( $retval ) { | |
if ( bp_is_members_directory() ) { | |
$exclude_ids = get_users( | |
array( | |
'fields' => 'ID', | |
'role__in' => array( 'editor', 'author' ) // change the roles here | |
) | |
); | |
$retval['exclude'] = $exclude_ids; | |
} | |
return $retval; | |
} | |
add_filter( 'bp_before_has_members_parse_args', 'exclude_roles_from_members_loop' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment