members_screen_list_sent_invites()

Catch and process the Pending Invites page.


Source Source

File: bp-members/screens/invitations.php

function members_screen_list_sent_invites() {

	// Chack if there's an invitation to cancel or resend.
	if ( isset( $_GET['action'], $_GET['invitation_id'] ) && $_GET['action'] && $_GET['invitation_id'] ) {
		$action        = wp_unslash( $_GET['action'] );
		$invitation_id = (int) wp_unslash( $_GET['invitation_id'] );
		$user_id       = bp_displayed_user_id();

		if ( 'cancel' === $action ) {
			// Check the nonce and delete the invitation.
			if ( bp_verify_nonce_request( 'bp_members_invitations_cancel_' . $invitation_id ) && bp_members_invitations_delete_by_id( $invitation_id ) ) {
				bp_core_add_message( __( 'Invitation successfully canceled.', 'buddypress' ) );
			} else {
				bp_core_add_message( __( 'There was a problem canceling that invitation.', 'buddypress' ), 'error' );
			}
		} elseif ( 'resend' === $action ) {
			// Check the nonce and resend the invitation.
			if ( bp_verify_nonce_request( 'bp_members_invitation_resend_' . $invitation_id ) && bp_members_invitation_resend_by_id( $invitation_id ) ) {
				bp_core_add_message( __( 'Invitation successfully resent.', 'buddypress' ) );
			} else {
				bp_core_add_message( __( 'There was a problem resending that invitation.', 'buddypress' ), 'error' );
			}
		} else {
			/**
			 * Hook here to handle custom actions.
			 *
			 * @since 8.0.0
			 *
			 * @param string $action        The action name.
			 * @param int    $invitation_id The invitation ID.
			 * @param int    $user_id       The displayed user ID.
			 */
			do_action( 'bp_members_invitations_list_invites_action', $action, $invitation_id, $user_id );
		}

		// Redirect.
		bp_core_redirect( bp_get_members_invitations_list_invites_permalink( $user_id ) );
	}

	/**
	 * Fires before the loading of template for the send membership invitations page.
	 *
	 * @since 8.0.0
	 */
	do_action( 'members_screen_list_sent_invites' );

	/**
	 * Filters the template used to display the send membership invitations page.
	 *
	 * @since 8.0.0
	 *
	 * @param string $template Path to the send membership invitations template to load.
	 */
	bp_core_load_template( apply_filters( 'members_template_list_sent_invites', 'members/single/invitations' ) );
}


Top ↑

Changelog Changelog

Changelog
Version Description
8.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.