BP_Media::total_group_media_count( int $group_id )

Count total media for the given group

Description

Parameters

$group_id

(Required)

Return

(array|bool|int)

Source

File: bp-media/classes/class-bp-media.php

1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
public static function total_group_media_count( $group_id = 0 ) {
    global $wpdb;
 
    $bp = buddypress();
 
    $count_sql = "SELECT COUNT(*) FROM {$bp->media->table_name} WHERE group_id = {$group_id}";
 
    $cache_group = 'bp_media_group_media_count';
 
    $cached = bp_core_get_incremented_cache( $count_sql, $cache_group );
    if ( false === $cached ) {
        $results = $wpdb->get_col( $count_sql );
        $total_count = intval( $results[0] );
        bp_core_set_incremented_cache( $count_sql, $cache_group, $total_count );
    } else {
        $total_count = $cached;
    }
 
    return $total_count;
}

Changelog

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.