[ 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 = isset( $_GET['action'] ) ? $_GET['action'] : false;
  27      $user_id        = isset( $_GET['user_id'] ) ? (int) $_GET['user_id'] : false;
  28      $group_id       = bp_get_current_group_id();
  29  
  30      if ( $request_action && $user_id && $group_id ) {
  31          if ( 'accept' === $request_action ) {
  32  
  33              // Check the nonce first.
  34              if ( ! check_admin_referer( 'groups_accept_membership_request' ) ) {
  35                  return false;
  36              }
  37  
  38              // Accept the membership request.
  39              if ( ! groups_accept_membership_request( false, $user_id, $group_id ) ) {
  40                  bp_core_add_message( __( 'There was an error accepting the membership request. Please try again.', 'buddypress' ), 'error' );
  41              } else {
  42                  bp_core_add_message( __( 'Group membership request accepted', 'buddypress' ) );
  43              }
  44  
  45          } elseif ( 'reject' === $request_action ) {
  46              /* Check the nonce first. */
  47              if ( ! check_admin_referer( 'groups_reject_membership_request' ) ) {
  48                  return false;
  49              }
  50  
  51              // Reject the membership request.
  52              if ( ! groups_reject_membership_request( false, $user_id, $group_id ) ) {
  53                  bp_core_add_message( __( 'There was an error rejecting the membership request. Please try again.', 'buddypress' ), 'error' );
  54              } else {
  55                  bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
  56              }
  57          }
  58  
  59          // Was the member added to the group?
  60          $membership_id = groups_is_user_member( $user_id, $group_id );
  61  
  62          /**
  63           * Fires before the redirect if a group membership request has been handled.
  64           *
  65           * @since 1.0.0
  66           *
  67           * @param int    $id             ID of the group that was edited.
  68           * @param string $request_action Membership request action being performed.
  69           * @param int    $membership_id  The membership ID of the new user; false if rejected.
  70           * @param int    $user_id        The ID of the requesting user.
  71           * @param int    $group_id       The ID of the requested group.
  72           */
  73          do_action( 'groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id, $user_id, $group_id );
  74          bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/membership-requests/' );
  75      }
  76  
  77      /**
  78       * Fires before the loading of the group membership request page template.
  79       *
  80       * @since 1.0.0
  81       *
  82       * @param int $id ID of the group that is being displayed.
  83       */
  84      do_action( 'groups_screen_group_admin_requests', $bp->groups->current_group->id );
  85  
  86      /**
  87       * Filters the template to load for a group's membership request page.
  88       *
  89       * @since 1.0.0
  90       *
  91       * @param string $value Path to a group's membership request template.
  92       */
  93      bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/home' ) );
  94  }
  95  add_action( 'bp_screens', 'groups_screen_group_admin_requests' );


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