[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-groups/screens/single/admin/ -> delete-group.php (source)

   1  <?php
   2  /**
   3   * Groups: Single group "Manage > Delete" screen handler
   4   *
   5   * @package BuddyPress
   6   * @subpackage GroupsScreens
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Handle the display of the Delete Group page.
  12   *
  13   * @since 1.0.0
  14   */
  15  function groups_screen_group_admin_delete_group() {
  16  
  17      if ( 'delete-group' != bp_get_group_current_admin_tab() )
  18          return false;
  19  
  20      if ( ! bp_is_item_admin() && !bp_current_user_can( 'bp_moderate' ) )
  21          return false;
  22  
  23      $bp = buddypress();
  24  
  25      if ( isset( $_REQUEST['delete-group-button'] ) && isset( $_REQUEST['delete-group-understand'] ) ) {
  26  
  27          // Check the nonce first.
  28          if ( !check_admin_referer( 'groups_delete_group' ) ) {
  29              return false;
  30          }
  31  
  32          /**
  33           * Fires before the deletion of a group from the Delete Group page.
  34           *
  35           * @since 1.5.0
  36           *
  37           * @param int $id ID of the group being deleted.
  38           */
  39          do_action( 'groups_before_group_deleted', $bp->groups->current_group->id );
  40  
  41          // Group admin has deleted the group, now do it.
  42          if ( !groups_delete_group( $bp->groups->current_group->id ) ) {
  43              bp_core_add_message( __( 'There was an error deleting the group. Please try again.', 'buddypress' ), 'error' );
  44          } else {
  45              bp_core_add_message( __( 'The group was deleted successfully.', 'buddypress' ) );
  46  
  47              /**
  48               * Fires after the deletion of a group from the Delete Group page.
  49               *
  50               * @since 1.0.0
  51               *
  52               * @param int $id ID of the group being deleted.
  53               */
  54              do_action( 'groups_group_deleted', $bp->groups->current_group->id );
  55  
  56              bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) );
  57          }
  58  
  59          bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) );
  60      }
  61  
  62      /**
  63       * Fires before the loading of the Delete Group page template.
  64       *
  65       * @since 1.0.0
  66       *
  67       * @param int $id ID of the group that is being displayed.
  68       */
  69      do_action( 'groups_screen_group_admin_delete_group', $bp->groups->current_group->id );
  70  
  71      /**
  72       * Filters the template to load for the Delete Group page.
  73       *
  74       * @since 1.0.0
  75       *
  76       * @param string $value Path to the Delete Group template.
  77       */
  78      bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/single/home' ) );
  79  }
  80  add_action( 'bp_screens', 'groups_screen_group_admin_delete_group' );


Generated: Thu Nov 21 01:00:57 2024 Cross-referenced by PHPXref 0.7.1