BP_Groups_Member::prime_group_admins_mods_cache( array $group_ids )
Prime the bp_group_admins cache for one or more groups.
Description
Parameters
- $group_ids
-
(Required) IDs of the groups.
Return
(bool) True on success.
Source
File: bp-groups/classes/class-bp-groups-member.php
public static function prime_group_admins_mods_cache( $group_ids ) { global $wpdb; $uncached = bp_get_non_cached_ids( $group_ids, 'bp_group_admins' ); if ( $uncached ) { $bp = buddypress(); $uncached_sql = implode( ',', array_map( 'intval', $uncached ) ); $group_admin_mods = $wpdb->get_results( "SELECT user_id, group_id, date_modified, is_admin, is_mod FROM {$bp->groups->table_name_members} WHERE group_id IN ({$uncached_sql}) AND ( is_admin = 1 OR is_mod = 1 ) AND is_banned = 0" ); $admins = $mods = array(); if ( $group_admin_mods ) { foreach ( $group_admin_mods as $group_admin_mod ) { $obj = new stdClass(); $obj->user_id = $group_admin_mod->user_id; $obj->date_modified = $group_admin_mod->date_modified; if ( $group_admin_mod->is_admin ) { $admins[ $group_admin_mod->group_id ][] = $obj; } else { $mods[ $group_admin_mod->group_id ][] = $obj; } } } // Prime cache for all groups, even those with no matches. foreach ( $uncached as $group_id ) { $group_admins = isset( $admins[ $group_id ] ) ? $admins[ $group_id ] : array(); wp_cache_set( $group_id, $group_admins, 'bp_group_admins' ); $group_mods = isset( $mods[ $group_id ] ) ? $mods[ $group_id ] : array(); wp_cache_set( $group_id, $group_mods, 'bp_group_mods' ); } } }
Changelog
Version | Description |
---|---|
BuddyPress 2.7.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.