bp_groups_admin_edit_metabox_members( BP_Groups_Group $item )
Renders the Members metabox on single group pages.
Description
Parameters
- $item
-
(Required) The BP_Groups_Group object for the current group.
Source
File: bp-groups/bp-groups-admin.php
function bp_groups_admin_edit_metabox_members( $item ) { // Pull up a list of group members, so we can separate out the types // We'll also keep track of group members here to place them into a // JavaScript variable, which will help with group member autocomplete. $members = array( 'admin' => array(), 'mod' => array(), 'member' => array(), 'banned' => array(), ); $pagination = array( 'admin' => array(), 'mod' => array(), 'member' => array(), 'banned' => array(), ); foreach ( $members as $type => &$member_type_users ) { $page_qs_key = $type . '_page'; $current_type_page = isset( $_GET[ $page_qs_key ] ) ? absint( $_GET[ $page_qs_key ] ) : 1; $member_type_query = new BP_Group_Member_Query( array( 'group_id' => $item->id, 'group_role' => array( $type ), 'type' => 'alphabetical', /** * Filters the admin members type per page value. * * @since BuddyPress 2.8.0 * * @param int $value profile types per page. Default 10. * @param string $type profile type. */ 'per_page' => apply_filters( 'bp_groups_admin_members_type_per_page', 10, $type ), 'page' => $current_type_page, ) ); $member_type_users = $member_type_query->results; $pagination[ $type ] = bp_groups_admin_create_pagination_links( $member_type_query, $type ); } // Echo out the JavaScript variable. echo '<script>var group_id = "' . esc_js( $item->id ) . '";</script>'; // Loop through each profile type. foreach ( $members as $member_type => $type_users ) : ?> <div class="bp-groups-member-type" id="bp-groups-member-type-<?php echo esc_attr( $member_type ) ?>"> <h3><?php switch ( $member_type ) : case 'admin' : esc_html_e( 'Organizers', 'buddyboss' ); break; case 'mod' : esc_html_e( 'Moderators', 'buddyboss' ); break; case 'member' : esc_html_e( 'Members', 'buddyboss' ); break; case 'banned' : esc_html_e( 'Banned Members', 'buddyboss' ); break; endswitch; ?></h3> <div class="bp-group-admin-pagination table-top"> <?php echo $pagination[ $member_type ] ?> </div> <?php if ( !empty( $type_users ) ) : ?> <table class="widefat bp-group-members"> <thead> <tr> <th scope="col" class="uid-column"><?php _e( 'ID', 'buddyboss' ); ?></th> <th scope="col" class="uname-column"><?php _e( 'Name', 'buddyboss' ); ?></th> <th scope="col" class="urole-column"><?php _e( 'Role', 'buddyboss' ); ?></th> </tr> </thead> <tbody> <?php foreach ( $type_users as $type_user ) : ?> <tr> <th scope="row" class="uid-column"><?php echo esc_html( $type_user->ID ); ?></th> <td class="uname-column"> <a style="float: left;" href="<?php echo bp_core_get_user_domain( $type_user->ID ); ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $type_user->ID, 'width' => '32', 'height' => '32' ) ); ?></a> <span style="margin: 8px; float: left;"><?php echo bp_core_get_userlink( $type_user->ID ); ?></span> </td> <td class="urole-column"> <label for="bp-groups-role-<?php echo esc_attr( $type_user->ID ); ?>" class="screen-reader-text"><?php /* translators: accessibility text */ _e( 'Select group role for member', 'buddyboss' ); ?></label> <select class="bp-groups-role" id="bp-groups-role-<?php echo esc_attr( $type_user->ID ); ?>" name="bp-groups-role[<?php echo esc_attr( $type_user->ID ); ?>]"> <optgroup label="<?php esc_attr_e( 'Roles', 'buddyboss' ); ?>"> <option class="admin" value="admin" <?php selected( 'admin', $member_type ); ?>><?php esc_html_e( 'Organizer', 'buddyboss' ); ?></option> <option class="mod" value="mod" <?php selected( 'mod', $member_type ); ?>><?php esc_html_e( 'Moderator', 'buddyboss' ); ?></option> <option class="member" value="member" <?php selected( 'member', $member_type ); ?>><?php esc_html_e( 'Member', 'buddyboss' ); ?></option> <?php if ( 'banned' === $member_type ) : ?> <option class="banned" value="banned" <?php selected( 'banned', $member_type ); ?>><?php esc_html_e( 'Banned', 'buddyboss' ); ?></option> <?php endif; ?> </optgroup> <optgroup label="<?php esc_attr_e( 'Actions', 'buddyboss' ); ?>"> <option class="remove" value="remove"><?php esc_html_e( 'Remove', 'buddyboss' ); ?></option> <?php if ( 'banned' !== $member_type ) : ?> <option class="banned" value="banned"><?php esc_html_e( 'Ban', 'buddyboss' ); ?></option> <?php endif; ?> </optgroup> </select> <?php /** * Store the current role for this user, * so we can easily detect changes. * * @todo remove this, and do database detection on save */ ?> <input type="hidden" name="bp-groups-existing-role[<?php echo esc_attr( $type_user->ID ); ?>]" value="<?php echo esc_attr( $member_type ); ?>" /> </td> </tr> <?php if ( has_filter( 'bp_groups_admin_manage_member_row' ) ) : ?> <tr> <td colspan="3"> <?php /** * Fires after the listing of a single row for members in a group on the group edit screen. * * @since BuddyPress 1.8.0 * * @param int $ID ID of the user being rendered. * @param BP_Groups_Group $item Object for the current group. */ do_action( 'bp_groups_admin_manage_member_row', $type_user->ID, $item ); ?> </td> </tr> <?php endif; ?> <?php endforeach; ?> </tbody> </table> <?php else : ?> <p class="bp-groups-no-members description"><?php esc_html_e( 'No members of this type', 'buddyboss' ); ?></p> <?php endif; ?> </div><!-- .bp-groups-member-type --> <?php endforeach; }
Changelog
Version | Description |
---|---|
BuddyPress 1.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.