BP_Groups_Member::get_group_administrator_ids( int $group_id )

Get a list of all a given group’s admins.

Description

Parameters

$group_id

(Required) ID of the group.

Return

(array) Info about group admins (user_id + date_modified).

Source

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

1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
public static function get_group_administrator_ids( $group_id ) {
    global $wpdb;
 
    if ( empty( $group_id ) ) {
        return array();
    }
 
    $group_admins = wp_cache_get( $group_id, 'bp_group_admins' );
 
    if ( false === $group_admins ) {
        self::prime_group_admins_mods_cache( array( $group_id ) );
        $group_admins = wp_cache_get( $group_id, 'bp_group_admins' );
    }
 
    if ( false === $group_admins ) {
        // The wp_cache_get is still coming up empty. Return an empty array.
        $group_admins = array();
    } else {
        // Cast the user_id property as an integer.
        foreach ( (array) $group_admins as $key => $data ) {
            $group_admins[ $key ]->user_id = (int) $group_admins[ $key ]->user_id;
        }
    }
 
    return $group_admins;
}

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.