Limiting BP_members to show only certain user levels (no subscriber or admin)
-
Does anyone know how to filter all member lists in Buddypress to only show users with the role of author or higher.
I do not want subscriber level users to show up in the member lists or the count
I have looked at the bp_has_members function and can not find a way to do it. I have also looked all over various filters available and I am stumped.
I have written the following code:
`
add_filter( ‘bp_core_get_paged_users_sql’, ‘bp_filter_only_members’ , 1, 9 );
add_filter( ‘bp_core_get_total_users_sql’, ‘bp_filter_only_members’ , 1, 9 );function bp_filter_only_members($sql, $object) {
$sql = str_replace(‘FROM’ , “,(SELECT meta_value FROM wp_usermeta WHERE meta_key = ‘wp_user_level’ AND user_id = u.ID) AS user_level FROM” , $sql ) ;
$sql = str_replace(‘ORDER BY’ , “HAVING user_level > 1 ORDER BY” , $sql) ;
return $sql;
}
`
The issue I am having is that the count is coming back wrong.Can anyone think of a better way than going directly to the SQL. I have thought about meta values and some other hacky ways of doing this,
can anyone help me out on this,
thanks,
Andrew
- The topic ‘Limiting BP_members to show only certain user levels (no subscriber or admin)’ is closed to new replies.