[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-groups/screens/single/admin/ -> edit-details.php (source)

   1  <?php
   2  /**
   3   * Groups: Single group "Manage > Details" screen handler
   4   *
   5   * @package BuddyPress
   6   * @subpackage GroupsScreens
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Handle the display of a group's admin/edit-details page.
  12   *
  13   * @since 1.0.0
  14   */
  15  function groups_screen_group_admin_edit_details() {
  16  
  17      if ( 'edit-details' != bp_get_group_current_admin_tab() )
  18          return false;
  19  
  20      if ( bp_is_item_admin() ) {
  21  
  22          $bp = buddypress();
  23  
  24          // If the edit form has been submitted, save the edited details.
  25          if ( isset( $_POST['save'] ) ) {
  26              // Check the nonce.
  27              if ( !check_admin_referer( 'groups_edit_group_details' ) )
  28                  return false;
  29  
  30              $group_notify_members = isset( $_POST['group-notify-members'] ) ? (int) $_POST['group-notify-members'] : 0;
  31  
  32              // Name and description are required and may not be empty.
  33              if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) ) {
  34                  bp_core_add_message( __( 'Groups must have a name and a description. Please try again.', 'buddypress' ), 'error' );
  35              } elseif ( ! groups_edit_base_group_details( array(
  36                  'group_id'       => bp_get_current_group_id(),
  37                  'name'           => $_POST['group-name'],
  38                  'slug'           => null, // @TODO: Add to settings pane? If yes, editable by site admin only, or allow group admins to do this?
  39                  'description'    => $_POST['group-desc'],
  40                  'notify_members' => $group_notify_members,
  41              ) ) ) {
  42                  bp_core_add_message( __( 'There was an error updating group details. Please try again.', 'buddypress' ), 'error' );
  43              } else {
  44                  bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
  45              }
  46  
  47              /**
  48               * Fires before the redirect if a group details has been edited and saved.
  49               *
  50               * @since 1.0.0
  51               *
  52               * @param int $id ID of the group that was edited.
  53               */
  54              do_action( 'groups_group_details_edited', $bp->groups->current_group->id );
  55  
  56              bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/edit-details/' );
  57          }
  58  
  59          /**
  60           * Fires before the loading of the group admin/edit-details page template.
  61           *
  62           * @since 1.0.0
  63           *
  64           * @param int $id ID of the group that is being displayed.
  65           */
  66          do_action( 'groups_screen_group_admin_edit_details', $bp->groups->current_group->id );
  67  
  68          /**
  69           * Filters the template to load for a group's admin/edit-details page.
  70           *
  71           * @since 1.0.0
  72           *
  73           * @param string $value Path to a group's admin/edit-details template.
  74           */
  75          bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/home' ) );
  76      }
  77  }
  78  add_action( 'bp_screens', 'groups_screen_group_admin_edit_details' );


Generated: Thu Apr 25 01:01:12 2024 Cross-referenced by PHPXref 0.7.1