[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Groups: Single group "Request Membership" 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 Request Membership page.
  12   *
  13   * @since 1.0.0
  14   */
  15  function groups_screen_group_request_membership() {
  16  
  17      if ( !is_user_logged_in() )
  18          return false;
  19  
  20      $bp = buddypress();
  21  
  22      if ( 'private' != $bp->groups->current_group->status )
  23          return false;
  24  
  25      // If the user is already invited, accept invitation.
  26      if ( groups_check_user_has_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
  27          if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
  28              bp_core_add_message( __( 'Group invite accepted', 'buddypress' ) );
  29          else
  30              bp_core_add_message( __( 'There was an error accepting the group invitation. Please try again.', 'buddypress' ), 'error' );
  31          bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
  32      }
  33  
  34      // If the user has submitted a request, send it.
  35      if ( isset( $_POST['group-request-send']) ) {
  36  
  37          // Check the nonce.
  38          if ( !check_admin_referer( 'groups_request_membership' ) )
  39              return false;
  40  
  41          if ( !groups_send_membership_request( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
  42              bp_core_add_message( __( 'There was an error sending your group membership request. Please try again.', 'buddypress' ), 'error' );
  43          } else {
  44              bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
  45          }
  46          bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
  47      }
  48  
  49      /**
  50       * Fires before the loading of a group's Request Memebership page.
  51       *
  52       * @since 1.0.0
  53       *
  54       * @param int $id ID of the group currently being displayed.
  55       */
  56      do_action( 'groups_screen_group_request_membership', $bp->groups->current_group->id );
  57  
  58      /**
  59       * Filters the template to load for a group's Request Membership page.
  60       *
  61       * @since 1.0.0
  62       *
  63       * @param string $value Path to a group's Request Membership template.
  64       */
  65      bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/single/home' ) );
  66  }


Generated: Fri Dec 13 01:01:36 2019 Cross-referenced by PHPXref 0.7.1