members_screen_send_invites()

Catch and process the Send Invites page.


Source Source

File: bp-members/screens/invitations.php

function members_screen_send_invites() {

	// Chack if there's an invitation to send.
	if ( isset( $_REQUEST['action'] ) && 'send-invite' === wp_unslash( $_REQUEST['action'] ) ) {
		$user_id      = bp_displayed_user_id();
		$default_args = array(
			'invitee_email' => '',
			'inviter_id'    => $user_id,
			'content'       => '',
			'send_invite'   => 1,
		);

		$invite_args = wp_parse_args( array_map( 'wp_unslash', $_REQUEST ), $default_args );
		$invite_args = array_intersect_key( $invite_args, $default_args );

		// Check the nonce and delete the invitation.
		if ( bp_verify_nonce_request( 'bp_members_invitation_send_' . $user_id ) && bp_members_invitations_invite_user( $invite_args ) ) {
			bp_core_add_message( __( 'Invitation successfully sent!', 'buddypress' )          );
		} else {
			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' );
		}

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

	/**
	 * Fires before the loading of template for the send membership invitations page.
	 *
	 * @since 8.0.0
	 */
	do_action( 'members_screen_send_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_send_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.