[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * BuddyPress Members: Invitations screens
   4   *
   5   * @package BuddyPress
   6   * @subpackage MembersScreens
   7   * @since 8.0.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * Catch and process the Send Invites page.
  15   *
  16   * @since 8.0.0
  17   */
  18  function members_screen_send_invites() {
  19  
  20      // Chack if there's an invitation to send.
  21      if ( isset( $_REQUEST['action'] ) && 'send-invite' === wp_unslash( $_REQUEST['action'] ) ) {
  22          $user_id      = bp_displayed_user_id();
  23          $default_args = array(
  24              'invitee_email' => '',
  25              'inviter_id'    => $user_id,
  26              'content'       => '',
  27              'send_invite'   => 1,
  28          );
  29  
  30          $invite_args = bp_parse_args(
  31              array_map( 'wp_unslash', $_REQUEST ),
  32              $default_args
  33          );
  34          $invite_args = array_intersect_key( $invite_args, $default_args );
  35  
  36          // Check the nonce and delete the invitation.
  37          if ( bp_verify_nonce_request( 'bp_members_invitation_send_' . $user_id ) && bp_members_invitations_invite_user( $invite_args ) ) {
  38              bp_core_add_message( __( 'Invitation successfully sent!', 'buddypress' )          );
  39          } else {
  40              bp_core_add_message( __( 'There was a problem sending that invitation. The user could already be a member of the site or have chosen not to receive invitations from this site.', 'buddypress' ), 'error' );
  41          }
  42  
  43          // Redirect.
  44          bp_core_redirect( bp_get_members_invitations_send_invites_permalink( $user_id ) );
  45      }
  46  
  47      /**
  48       * Fires before the loading of template for the send membership invitations page.
  49       *
  50       * @since 8.0.0
  51       */
  52      do_action( 'members_screen_send_invites' );
  53  
  54      /**
  55       * Filters the template used to display the send membership invitations page.
  56       *
  57       * @since 8.0.0
  58       *
  59       * @param string $template Path to the send membership invitations template to load.
  60       */
  61      bp_core_load_template( apply_filters( 'members_template_send_invites', 'members/single/invitations' ) );
  62  }
  63  
  64  /**
  65   * Catch and process the Pending Invites page.
  66   *
  67   * @since 8.0.0
  68   */
  69  function members_screen_list_sent_invites() {
  70  
  71      // Chack if there's an invitation to cancel or resend.
  72      if ( isset( $_GET['action'], $_GET['invitation_id'] ) && $_GET['action'] && $_GET['invitation_id'] ) {
  73          $action        = wp_unslash( $_GET['action'] );
  74          $invitation_id = (int) wp_unslash( $_GET['invitation_id'] );
  75          $user_id       = bp_displayed_user_id();
  76  
  77          if ( 'cancel' === $action ) {
  78              // Check the nonce and delete the invitation.
  79              if ( bp_verify_nonce_request( 'bp_members_invitations_cancel_' . $invitation_id ) && bp_members_invitations_delete_by_id( $invitation_id ) ) {
  80                  bp_core_add_message( __( 'Invitation successfully canceled.', 'buddypress' ) );
  81              } else {
  82                  bp_core_add_message( __( 'There was a problem canceling that invitation.', 'buddypress' ), 'error' );
  83              }
  84          } elseif ( 'resend' === $action ) {
  85              // Check the nonce and resend the invitation.
  86              if ( bp_verify_nonce_request( 'bp_members_invitation_resend_' . $invitation_id ) && bp_members_invitation_resend_by_id( $invitation_id ) ) {
  87                  bp_core_add_message( __( 'Invitation successfully resent.', 'buddypress' ) );
  88              } else {
  89                  bp_core_add_message( __( 'There was a problem resending that invitation.', 'buddypress' ), 'error' );
  90              }
  91          } else {
  92              /**
  93               * Hook here to handle custom actions.
  94               *
  95               * @since 8.0.0
  96               *
  97               * @param string $action        The action name.
  98               * @param int    $invitation_id The invitation ID.
  99               * @param int    $user_id       The displayed user ID.
 100               */
 101              do_action( 'bp_members_invitations_list_invites_action', $action, $invitation_id, $user_id );
 102          }
 103  
 104          // Redirect.
 105          bp_core_redirect( bp_get_members_invitations_list_invites_permalink( $user_id ) );
 106      }
 107  
 108      /**
 109       * Fires before the loading of template for the send membership invitations page.
 110       *
 111       * @since 8.0.0
 112       */
 113      do_action( 'members_screen_list_sent_invites' );
 114  
 115      /**
 116       * Filters the template used to display the send membership invitations page.
 117       *
 118       * @since 8.0.0
 119       *
 120       * @param string $template Path to the send membership invitations template to load.
 121       */
 122      bp_core_load_template( apply_filters( 'members_template_list_sent_invites', 'members/single/invitations' ) );
 123  }


Generated: Sun Dec 22 01:00:54 2024 Cross-referenced by PHPXref 0.7.1