BP_Groups_Group::set_up_admins_and_mods()
Set up admins and mods for the current group object.
Description
Called only when the ‘admins’ or ‘mods’ property is accessed.
Source
File: bp-groups/classes/class-bp-groups-group.php
protected function set_up_admins_and_mods() { $admin_ids = BP_Groups_Member::get_group_administrator_ids( $this->id ); $admin_ids_plucked = wp_list_pluck( $admin_ids, 'user_id' ); $mod_ids = BP_Groups_Member::get_group_moderator_ids( $this->id ); $mod_ids_plucked = wp_list_pluck( $mod_ids, 'user_id' ); $admin_mod_ids = array_merge( $admin_ids_plucked, $mod_ids_plucked ); $admin_mod_users = array(); if ( ! empty( $admin_mod_ids ) ) { $admin_mod_users = get_users( array( 'include' => $admin_mod_ids, 'blog_id' => null, ) ); } $admin_objects = $mod_objects = array(); foreach ( $admin_mod_users as $admin_mod_user ) { $obj = new stdClass(); $obj->user_id = $admin_mod_user->ID; $obj->user_login = $admin_mod_user->user_login; $obj->user_email = $admin_mod_user->user_email; $obj->user_nicename = $admin_mod_user->user_nicename; if ( in_array( $admin_mod_user->ID, $admin_ids_plucked, true ) ) { $obj->is_admin = 1; $obj->is_mod = 0; $admin_objects[] = $obj; } else { $obj->is_admin = 0; $obj->is_mod = 1; $mod_objects[] = $obj; } } $this->admins = $admin_objects; $this->mods = $mod_objects; }
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.