this is WordPress related not bbpress, suggest you post to WordPress support
Thanks for the feedback, @robin-w.
I noticed the anchor element with the class “bbp-glance-users” (from bbpress/includes/admin/metaboxes.php), which appears in the dashboard_right_now/”At a Glance” widget, is exclusively created by the bbPress plugin through the ‘dashboard_glance_items’ WordPress hook. For a multisite, the Users count is coming from the entire network.
I’ve traced the Users count number back to this function (from bbpress/includes/core/abstraction.php):
function bbp_get_total_users() {
$bbp_db = bbp_db();
$count = $bbp_db->get_var( “SELECT COUNT(ID) as c FROM {$bbp_db->users} WHERE user_status = ‘0’” );
// Filter & return
return (int) apply_filters( ‘bbp_get_total_users’, (int) $count );
}
And I was wondering if this could be updated to check if the site is a multisite and then select the Users based on the individual site ID.
Thanks,
Matthew Huntley
Seems you should be able to add a filter and return that instead which would override the function you listed above.
I don’t have a multi site set up with bbpress, but try the below and see if that works for you. Would have to add to the code snippets plugin or your theme’s functions.php file
if( !function_exists('mh_bbp_get_multi_site_total_users') ){
function mh_bbp_get_multi_site_total_users( $count ) {
if ( is_multisite() ) {
$args = array(
'blog_id' => get_current_blog_id(),
'fields' => 'ID'
);
$count = count( (array) get_users( $args ) );
}
return (int) $count;
}
add_filter( 'bbp_get_total_users' , 'mh_bbp_get_multi_site_total_users', 100 );
}
Thank you very much, @webcreations907. Your solution is working well so far. I appreciate the expedited response.
Best regards,
Matthew Huntley