BP_Groups_Group::get_total_group_count()

Get a total group count for the site.

Description

Will include hidden groups in the count only if bp_current_user_can( ‘bp_moderate’ ).

Return

(int) Group count.

Source

File: bp-groups/classes/class-bp-groups-group.php

	public static function get_total_group_count() {
		global $wpdb;

		$hidden_sql = '';
		if ( !bp_current_user_can( 'bp_moderate' ) )
			$hidden_sql = "WHERE status != 'hidden'";

		$bp = buddypress();

		return $wpdb->get_var( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql}" );
	}

Changelog

Changelog
Version Description
BuddyPress 1.6.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.