[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-groups/screens/single/admin/ -> membership-requests.php (source)

   1  <?php
   2  /**
   3   * Groups: Single group "Manage > Requests" screen handler
   4   *
   5   * @package BuddyPress
   6   * @subpackage GroupsScreens
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Handle the display of Admin > Membership Requests.
  12   *
  13   * @since 1.0.0
  14   */
  15  function groups_screen_group_admin_requests() {
  16      $bp = buddypress();
  17  
  18      if ( 'membership-requests' != bp_get_group_current_admin_tab() ) {
  19          return false;
  20      }
  21  
  22      if ( ! bp_is_item_admin() || ( 'public' == $bp->groups->current_group->status ) ) {
  23          return false;
  24      }
  25  
  26      $request_action = (string) bp_action_variable( 1 );
  27      $membership_id  = (int) bp_action_variable( 2 );
  28  
  29      if ( !empty( $request_action ) && !empty( $membership_id ) ) {
  30          if ( 'accept' == $request_action && is_numeric( $membership_id ) ) {
  31  
  32              // Check the nonce first.
  33              if ( !check_admin_referer( 'groups_accept_membership_request' ) )
  34                  return false;
  35  
  36              // Accept the membership request.
  37              if ( !groups_accept_membership_request( $membership_id ) )
  38                  bp_core_add_message( __( 'There was an error accepting the membership request. Please try again.', 'buddypress' ), 'error' );
  39              else
  40                  bp_core_add_message( __( 'Group membership request accepted', 'buddypress' ) );
  41  
  42          } elseif ( 'reject' == $request_action && is_numeric( $membership_id ) ) {
  43              /* Check the nonce first. */
  44              if ( !check_admin_referer( 'groups_reject_membership_request' ) )
  45                  return false;
  46  
  47              // Reject the membership request.
  48              if ( !groups_reject_membership_request( $membership_id ) )
  49                  bp_core_add_message( __( 'There was an error rejecting the membership request. Please try again.', 'buddypress' ), 'error' );
  50              else
  51                  bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
  52          }
  53  
  54          /**
  55           * Fires before the redirect if a group membership request has been handled.
  56           *
  57           * @since 1.0.0
  58           *
  59           * @param int    $id             ID of the group that was edited.
  60           * @param string $request_action Membership request action being performed.
  61           * @param int    $membership_id  The key of the action_variables array that you want.
  62           */
  63          do_action( 'groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id );
  64          bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/membership-requests/' );
  65      }
  66  
  67      /**
  68       * Fires before the loading of the group membership request page template.
  69       *
  70       * @since 1.0.0
  71       *
  72       * @param int $id ID of the group that is being displayed.
  73       */
  74      do_action( 'groups_screen_group_admin_requests', $bp->groups->current_group->id );
  75  
  76      /**
  77       * Filters the template to load for a group's membership request page.
  78       *
  79       * @since 1.0.0
  80       *
  81       * @param string $value Path to a group's membership request template.
  82       */
  83      bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/home' ) );
  84  }
  85  add_action( 'bp_screens', 'groups_screen_group_admin_requests' );


Generated: Fri Jul 19 01:01:43 2019 Cross-referenced by PHPXref 0.7.1