[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Members: Send Invitations
   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_send_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_send_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_send_invites', 'members/single/invitations' ) );
  32  }
  33  
  34  /**
  35   * Handle sending invitations.
  36   *
  37   * @since 8.0.0
  38   *
  39   * @return bool
  40   */
  41  function bp_network_invitations_catch_send_action() {
  42  
  43      // Bail if not the read screen.
  44      if ( ! bp_is_user_members_invitations_send_screen() ) {
  45          return false;
  46      }
  47  
  48      // Get the action.
  49      $action  = ! empty( $_REQUEST['action']          ) ? $_REQUEST['action']          : '';
  50      $nonce   = ! empty( $_REQUEST['_wpnonce']        ) ? $_REQUEST['_wpnonce']        : '';
  51      $email   = ! empty( $_REQUEST['invitee_email']   ) ? $_REQUEST['invitee_email']   : '';
  52      $message = ! empty( $_REQUEST['invite_message']  ) ? $_REQUEST['invite_message']  : '';
  53  
  54      // Bail if missing required info.
  55      if ( ( 'send-invite' !== $action ) ) {
  56          return false;
  57      }
  58  
  59      $invite_args = array(
  60          'invitee_email' => $email,
  61          'inviter_id'    => bp_displayed_user_id(),
  62          'content'       => $message,
  63          'send_invite'   => 1
  64      );
  65  
  66      // Check the nonce and delete the invitation.
  67      if ( bp_verify_nonce_request( 'bp_members_invitation_send_' . bp_displayed_user_id() ) && bp_members_invitations_invite_user( $invite_args ) ) {
  68          bp_core_add_message( __( 'Invitation successfully sent!', 'buddypress' )          );
  69      } else {
  70          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' );
  71      }
  72  
  73      // Redirect.
  74      $user_id = bp_displayed_user_id();
  75      bp_core_redirect( bp_get_members_invitations_send_invites_permalink( $user_id ) );
  76  }
  77  add_action( 'bp_actions', 'bp_network_invitations_catch_send_action' );


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