bp_get_group_ids_by_group_types( string $group_type = '', string $taxonomy = 'bp_group_type' )
Get group count of group type tabs groups.
Description
Parameters
- $group_type
-
(Optional) The group type.
Default value: ''
- $taxonomy
-
(Optional) The group taxonomy.
Default value: 'bp_group_type'
Source
File: bp-groups/bp-groups-functions.php
function bp_get_group_ids_by_group_types( $group_type = '', $taxonomy = 'bp_group_type' ) {
global $wpdb, $bp;
$group_types = bp_groups_get_group_types();
if ( empty( $group_type ) || empty( $group_types[ $group_type ] ) ) {
return false;
}
if ( ! bp_is_root_blog() ) {
switch_to_blog( bp_get_root_blog_id() );
}
$bp_group_type_query = array(
'select' => "SELECT t.slug, tt.term_id 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 ) );
restore_current_blog();
$bp_group_type_count = wp_filter_object_list( $bp_get_group_type_count, array( 'slug' => $group_type ), 'and', 'term_id' );
$bp_group_type_count = array_values( $bp_group_type_count );
if ( empty( $bp_group_type_count ) ) {
return 0;
}
$taxonomy_id = (int) $bp_group_type_count[0];
$groups = $bp->table_prefix . 'bp_groups';
$group_meta = $bp->table_prefix . 'bp_groups_groupmeta';
$term_relationships = $wpdb->term_relationships;
$query = "SELECT g.id as id FROM $groups g JOIN $group_meta gm_last_activity on ( g.id = gm_last_activity.group_id ) WHERE g.id IN ( SELECT object_id FROM $term_relationships WHERE $term_relationships.term_taxonomy_id IN ($taxonomy_id) ) AND gm_last_activity.meta_key = 'last_activity'";
$results = $wpdb->get_results( $query, ARRAY_A );
return $results;
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.0.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.