bp_get_total_count_by_group_types( string $group_type = '', string $taxonomy = 'bp_group_type' )

Get group count of group type tabs groups.

Description

Parameters

$group_type

(string) (Optional) The group type.

Default value: ''

$taxonomy

(string) (Optional) The group taxonomy.

Default value: 'bp_group_type'

Source

File: bp-core/deprecated/buddyboss/1.1.8.php

function bp_get_total_count_by_group_types( $group_type = '', $taxonomy = 'bp_group_type' ) {

	global $wpdb;

	$group_types = bp_groups_get_group_types();

	if ( empty( $group_type ) || empty( $group_types[ $group_type ] ) ) {
		return false;
	}

	$bp_get_group_type_count = wp_cache_get( 'bp_get_total_count_by_group_types', 'bp_group_type_total_count_group' );

	if ( ! $bp_get_group_type_count ) {
		if ( ! bp_is_root_blog() ) {
			switch_to_blog( bp_get_root_blog_id() );
		}
		$bp_group_type_query         = array(
			'select' => "SELECT t.slug, tt.count FROM {$wpdb->term_taxonomy} tt LEFT JOIN {$wpdb->terms} t",
			'on'     => 'ON tt.term_id = t.term_id',
			'where'  => $wpdb->prepare( 'WHERE tt.taxonomy = %s', $taxonomy ),
		);
		$bp_get_group_type_count = $wpdb->get_results( join( ' ', $bp_group_type_query ) );
		wp_cache_set( 'bp_get_total_count_by_group_types', $bp_get_group_type_count, 'bp_group_type_total_count_group' );
		restore_current_blog();
	}
	$bp_group_type_count = wp_filter_object_list( $bp_get_group_type_count, array( 'slug' => $group_type ), 'and', 'count' );
	$bp_group_type_count = array_values( $bp_group_type_count );
	if ( empty( $bp_group_type_count ) ) {
		return 0;
	}
	return (int) $bp_group_type_count[0];
}

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.