[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-members/screens/ -> list-invites.php (source)

   1  <?php
   2  /**
   3   * Members: Sent Invitations Status
   4   *
   5   * @package BuddyPress
   6   * @subpackage MembersScreens
   7   * @since 8.0.0
   8   */
   9  
  10  /**
  11   * Catch and process the Send Invites page.
  12   *
  13   * @since 8.0.0
  14   */
  15  function members_screen_list_sent_invites() {
  16  
  17      /**
  18       * Fires before the loading of template for the send membership invitations page.
  19       *
  20       * @since 8.0.0
  21       */
  22      do_action( 'members_screen_list_sent_invites' );
  23  
  24      /**
  25       * Filters the template used to display the send membership invitations page.
  26       *
  27       * @since 8.0.0
  28       *
  29       * @param string $template Path to the send membership invitations template to load.
  30       */
  31      bp_core_load_template( apply_filters( 'members_template_list_sent_invites', 'members/single/invitations' ) );
  32  }
  33  
  34  /**
  35   * Handle canceling or resending single invitations.
  36   *
  37   * @since 8.0.0
  38   *
  39   * @return bool
  40   */
  41  function bp_members_invitations_action_handling() {
  42  
  43      // Bail if not the read screen.
  44      if ( ! bp_is_user_members_invitations_list() ) {
  45          return false;
  46      }
  47  
  48      // Get the action.
  49      $action = ! empty( $_GET['action']        ) ? $_GET['action']        : '';
  50      $nonce  = ! empty( $_GET['_wpnonce']      ) ? $_GET['_wpnonce']      : '';
  51      $id     = ! empty( $_GET['invitation_id'] ) ? $_GET['invitation_id'] : '';
  52  
  53      // Bail if no action or no ID.
  54      if ( empty( $action ) || empty( $id ) ) {
  55          return false;
  56      }
  57  
  58      if ( 'cancel' === $action ) {
  59          // Check the nonce and delete the invitation.
  60          if ( bp_verify_nonce_request( 'bp_members_invitations_cancel_' . $id ) && bp_members_invitations_delete_by_id( $id ) ) {
  61              bp_core_add_message( __( 'Invitation successfully canceled.', 'buddypress' ) );
  62          } else {
  63              bp_core_add_message( __( 'There was a problem canceling that invitation.', 'buddypress' ), 'error' );
  64          }
  65      } else if ( 'resend' === $action ) {
  66          // Check the nonce and resend the invitation.
  67          if ( bp_verify_nonce_request( 'bp_network_invitation_resend_' . $id ) && bp_members_invitation_resend_by_id( $id ) ) {
  68              bp_core_add_message( __( 'Invitation successfully resent.', 'buddypress' ) );
  69          } else {
  70              bp_core_add_message( __( 'There was a problem resending that invitation.', 'buddypress' ), 'error' );
  71          }
  72      } else {
  73          return false;
  74      }
  75  
  76      // Redirect.
  77      $user_id = bp_displayed_user_id();
  78      bp_core_redirect( bp_get_members_invitations_list_invites_permalink( $user_id ) );
  79  }
  80  add_action( 'bp_actions', 'bp_members_invitations_action_handling' );


Generated: Mon May 17 01:01:38 2021 Cross-referenced by PHPXref 0.7.1