BP_REST_Groups_Details_Endpoint::get_group_tab_count( sting $slug, string $type )

Get group count for the tab.

Description

Parameters

$slug

(Required) Group tab object slug.

$type

(Required) Active, newest, alphabetical, random, popular.

Return

(int)

Source

File: bp-groups/classes/class-bp-rest-groups-details-endpoint.php

563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
protected function get_group_tab_count( $slug, $type ) {
    $count   = 0;
    $user_id = ! empty( get_current_user_id() ) ? ( get_current_user_id() ) : false;
 
    switch ( $slug ) {
        case 'all':
            $groups = groups_get_groups( array( 'type' => $type ) );
            if ( ! empty( $groups ) && isset( $groups['total'] ) ) {
                $count = $groups['total'];
            }
            break;
        case 'personal':
            $groups = groups_get_groups(
                array(
                    'type'    => $type,
                    'user_id' => $user_id,
                )
            );
            if ( ! empty( $groups ) && isset( $groups['total'] ) ) {
                $count = $groups['total'];
            }
            break;
    }
 
    return $count;
}

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.