[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-groups/screens/user/ -> invites.php (source)

   1  <?php
   2  /**
   3   * Groups: User's "Groups > Invites" screen handler
   4   *
   5   * @package BuddyPress
   6   * @subpackage GroupScreens
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Handle the loading of a user's Groups > Invites page.
  12   *
  13   * @since 1.0.0
  14   */
  15  function groups_screen_group_invites() {
  16      $group_id = (int)bp_action_variable( 1 );
  17  
  18      if ( bp_is_action_variable( 'accept' ) && is_numeric( $group_id ) ) {
  19          // Check the nonce.
  20          if ( !check_admin_referer( 'groups_accept_invite' ) )
  21              return false;
  22  
  23          if ( !groups_accept_invite( bp_loggedin_user_id(), $group_id ) ) {
  24              bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' );
  25          } else {
  26              // Record this in activity streams.
  27              $group = groups_get_group( $group_id );
  28  
  29              bp_core_add_message( sprintf( __( 'Group invite accepted. Visit %s.', 'buddypress' ), bp_get_group_link( $group ) ) );
  30  
  31              if ( bp_is_active( 'activity' ) ) {
  32                  groups_record_activity( array(
  33                      'type'    => 'joined_group',
  34                      'item_id' => $group->id
  35                  ) );
  36              }
  37          }
  38  
  39          if ( isset( $_GET['redirect_to'] ) ) {
  40              $redirect_to = urldecode( $_GET['redirect_to'] );
  41          } else {
  42              $redirect_to = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action() );
  43          }
  44  
  45          bp_core_redirect( $redirect_to );
  46  
  47      } elseif ( bp_is_action_variable( 'reject' ) && is_numeric( $group_id ) ) {
  48          // Check the nonce.
  49          if ( !check_admin_referer( 'groups_reject_invite' ) )
  50              return false;
  51  
  52          if ( !groups_reject_invite( bp_loggedin_user_id(), $group_id ) ) {
  53              bp_core_add_message( __( 'Group invite could not be rejected', 'buddypress' ), 'error' );
  54          } else {
  55              bp_core_add_message( __( 'Group invite rejected', 'buddypress' ) );
  56          }
  57  
  58          if ( isset( $_GET['redirect_to'] ) ) {
  59              $redirect_to = urldecode( $_GET['redirect_to'] );
  60          } else {
  61              $redirect_to = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action() );
  62          }
  63  
  64          bp_core_redirect( $redirect_to );
  65      }
  66  
  67      /**
  68       * Fires before the loading of a users Groups > Invites template.
  69       *
  70       * @since 1.0.0
  71       *
  72       * @param int $group_id ID of the group being displayed
  73       */
  74      do_action( 'groups_screen_group_invites', $group_id );
  75  
  76      /**
  77       * Filters the template to load for a users Groups > Invites page.
  78       *
  79       * @since 1.0.0
  80       *
  81       * @param string $value Path to a users Groups > Invites page template.
  82       */
  83      bp_core_load_template( apply_filters( 'groups_template_group_invites', 'members/single/home' ) );
  84  }


Generated: Wed Nov 20 01:01:38 2019 Cross-referenced by PHPXref 0.7.1