Doesn't list members properly
-
Hello,
then using the standard BuddyPress list of members, it lists all the wp_users regardless of what subsite they have access to. Since this plugin is about creating different groups for each subsite I think it makes sense to separate this.
I added this code to get it done:
add_action( 'bp_pre_user_query', 'fv_bp_pre_user_query' ); function fv_bp_pre_user_query( $buddypress ) { global $wpdb; $buddypress->uid_clauses['where'] = "WHERE u.ID IN ( SELECT ID FROM {$wpdb->users} AS u JOIN {$wpdb->usermeta} AS m ON u.ID = m.user_id WHERE meta_key = '{$wpdb->prefix}user_level' AND spam = 0 AND deleted = 0 AND user_status = 0 )"; }
Next I had to also fix the total user count as that’s determined by a different query which is not filtered by above:
add_action( 'bp_user_query_populate_extras', 'fv_bp_fix_total_users' ); function fv_bp_fix_total_users( $buddypress ) { if( $buddypress->query_vars['user_id'] == 0 && !$buddypress->query_vars['exclude'] && !$buddypress->query_vars['search_terms'] && !$buddypress->query_vars['meta_key'] && !$buddypress->query_vars['meta_value'] && !$buddypress->query_vars['include'] ) { set_transient( 'bp_active_member_count', $buddypress->total_users ); } }
If you could test this and include in next release, that would be great as we wouln’t have to maintain this fix and your plugin would benefit from it.
Thanks!
Martin
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Doesn't list members properly’ is closed to new replies.