bp_groups_admin_edit()
Display the single groups edit screen.
Description
Source
File: bp-groups/bp-groups-admin.php
function bp_groups_admin_edit() { if ( ! bp_current_user_can( 'bp_moderate' ) ) die( '-1' ); $messages = array(); // If the user has just made a change to a group, build status messages. if ( !empty( $_REQUEST['no_admins'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) || ! empty( $_REQUEST['error_new'] ) || ! empty( $_REQUEST['success_new'] ) || ! empty( $_REQUEST['error_modified'] ) || ! empty( $_REQUEST['success_modified'] ) ) { $no_admins = ! empty( $_REQUEST['no_admins'] ) ? 1 : 0; $errors = ! empty( $_REQUEST['error'] ) ? $_REQUEST['error'] : ''; $updated = ! empty( $_REQUEST['updated'] ) ? $_REQUEST['updated'] : ''; $error_new = ! empty( $_REQUEST['error_new'] ) ? explode( ',', $_REQUEST['error_new'] ) : array(); $success_new = ! empty( $_REQUEST['success_new'] ) ? explode( ',', $_REQUEST['success_new'] ) : array(); $error_modified = ! empty( $_REQUEST['error_modified'] ) ? explode( ',', $_REQUEST['error_modified'] ) : array(); $success_modified = ! empty( $_REQUEST['success_modified'] ) ? explode( ',', $_REQUEST['success_modified'] ) : array(); if ( ! empty( $no_admins ) ) { $messages[] = __( 'This group must have at least one organizer.', 'buddyboss' ); } if ( ! empty( $errors ) ) { if ( $errors < 0 ) { $messages[] = __( 'Group name, slug, and description are all required fields.', 'buddyboss' ); } else { $messages[] = __( 'An error occurred when trying to update your group details.', 'buddyboss' ); } } elseif ( ! empty( $updated ) ) { $messages[] = __( 'The group has been updated successfully.', 'buddyboss' ); } if ( ! empty( $error_new ) ) { $messages[] = sprintf( __( 'The following users could not be added to the group: %s', 'buddyboss' ), '<em>' . esc_html( implode( ', ', $error_new ) ) . '</em>' ); } if ( ! empty( $success_new ) ) { $messages[] = sprintf( __( 'The following users were successfully added to the group: %s', 'buddyboss' ), '<em>' . esc_html( implode( ', ', $success_new ) ) . '</em>' ); } if ( ! empty( $error_modified ) ) { $error_modified = bp_groups_admin_get_usernames_from_ids( $error_modified ); $messages[] = sprintf( __( 'An error occurred when trying to modify the following members: %s', 'buddyboss' ), '<em>' . esc_html( implode( ', ', $error_modified ) ) . '</em>' ); } if ( ! empty( $success_modified ) ) { $success_modified = bp_groups_admin_get_usernames_from_ids( $success_modified ); $messages[] = sprintf( __( 'The following members were successfully modified: %s', 'buddyboss' ), '<em>' . esc_html( implode( ', ', $success_modified ) ) . '</em>' ); } } $is_error = ! empty( $no_admins ) || ! empty( $errors ) || ! empty( $error_new ) || ! empty( $error_modified ); // Get the group from the database. $group = groups_get_group( (int) $_GET['gid'] ); $group_name = isset( $group->name ) ? bp_get_group_name( $group ) : ''; // Construct URL for form. $form_url = remove_query_arg( array( 'action', 'deleted', 'no_admins', 'error', 'error_new', 'success_new', 'error_modified', 'success_modified' ), $_SERVER['REQUEST_URI'] ); $form_url = add_query_arg( 'action', 'save', $form_url ); /** * Fires before the display of the edit form. * * Useful for plugins to modify the group before display. * * @since BuddyPress 1.7.0 * * @param BP_Groups_Group $this Instance of the current group being edited. Passed by reference. */ do_action_ref_array( 'bp_groups_admin_edit', array( &$group ) ); ?> <div class="wrap"> <?php if ( version_compare( $GLOBALS['wp_version'], '4.8', '>=' ) ) : ?> <h1 class="wp-heading-inline"><?php _e( 'Edit Group', 'buddyboss' ); ?></h1> <?php if ( is_user_logged_in() && bp_user_can_create_groups() ) : ?> <a class="page-title-action" href="<?php echo esc_url( add_query_arg([ 'page' => 'bp-groups', 'create' => 'create-from-admin', 'action' => 'edit', ], admin_url( 'admin.php' ) ) ); ?>"><?php _e( 'New Group', 'buddyboss' ); ?></a> <?php endif; ?> <hr class="wp-header-end"> <?php else : ?> <h1><?php _e( 'Edit Group', 'buddyboss' ); ?> <?php if ( is_user_logged_in() && bp_user_can_create_groups() ) : ?> <a class="add-new-h2" href="<?php echo esc_url( add_query_arg([ 'page' => 'bp-groups', 'create' => 'create-from-admin', 'action' => 'edit', ], admin_url( 'admin.php' ) ) ); ?>"><?php _e( 'New Group', 'buddyboss' ); ?></a> <?php endif; ?> </h1> <?php endif; ?> <?php // If the user has just made a change to an group, display the status messages. ?> <?php if ( !empty( $messages ) ) : ?> <div id="moderated" class="<?php echo ( $is_error ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "</p><p>", $messages ); ?></p></div> <?php endif; ?> <?php if ( $group->id ) : ?> <form action="<?php echo esc_url( $form_url ); ?>" id="bp-groups-edit-form" method="post"> <div id="poststuff"> <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> <div id="post-body-content"> <div id="postdiv"> <div id="bp_groups_name" class="postbox"> <h2><?php _e( 'Name and Description', 'buddyboss' ); ?></h2> <div class="inside"> <label for="bp-groups-name" class="screen-reader-text"><?php /* translators: accessibility text */ _e( 'Group Name', 'buddyboss' ); ?></label> <input type="text" name="bp-groups-name" id="bp-groups-name" value="<?php echo esc_attr( stripslashes( $group_name ) ) ?>" /> <div id="bp-groups-permalink-box"> <strong><?php esc_html_e( 'Permalink:', 'buddyboss' ) ?></strong> <span id="bp-groups-permalink"> <?php bp_groups_directory_permalink(); ?> <input type="text" id="bp-groups-slug" name="bp-groups-slug" value="<?php bp_group_slug( $group ); ?>" autocomplete="off"> / </span> <a href="<?php echo bp_group_permalink( $group ) ?>" class="button button-small" id="bp-groups-visit-group"><?php esc_html_e( 'Visit Group', 'buddyboss' ) ?></a> </div> <label for="bp-groups-description" class="screen-reader-text"><?php /* translators: accessibility text */ _e( 'Group Description', 'buddyboss' ); ?></label> <?php wp_editor( stripslashes( $group->description ), 'bp-groups-description', array( 'media_buttons' => false, 'teeny' => true, 'textarea_rows' => 5, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?> </div> </div> </div> </div><!-- #post-body-content --> <div id="postbox-container-1" class="postbox-container"> <?php do_meta_boxes( get_current_screen()->id, 'side', $group ); ?> </div> <div id="postbox-container-2" class="postbox-container"> <?php do_meta_boxes( get_current_screen()->id, 'normal', $group ); ?> <?php do_meta_boxes( get_current_screen()->id, 'advanced', $group ); ?> </div> </div><!-- #post-body --> </div><!-- #poststuff --> <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> <?php wp_nonce_field( 'edit-group_' . $group->id ); ?> </form> <?php else : ?> <p><?php printf( '%1$s <a href="%2$s">%3$s</a>', __( 'No group found with this ID.', 'buddyboss' ), esc_url( bp_get_admin_url( 'admin.php?page=bp-groups' ) ), __( 'Go back and try again.', 'buddyboss' ) ); ?></p> <?php endif; ?> </div><!-- .wrap --> <?php }
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.