BP_Members_Invitation_Manager::run_acceptance_action( string $type, array $r )

This is where custom actions are added to run when an invitation or request is accepted.


Parameters Parameters

$type

(string) (Required) Are we accepting an invitation or request?

$r

(array) (Required) Parameters that describe the invitation being accepted.


Top ↑

Return Return

(bool) True on success, false on failure.


Source Source

File: bp-members/classes/class-bp-members-invitation-manager.php

	public function run_acceptance_action( $type, $r ) {
		if ( ! $type || ! in_array( $type, array( 'request', 'invite' ), true ) ) {
			return false;
		}

		if ( 'invite' === $type ) {

			$invites = $this->get_invitations( $r );
			if ( ! $invites ) {
				return;
			}

			foreach ( $invites as $invite ) {
				// Add the accepted invitation ID to the user's meta.
				$new_user = get_user_by( 'email', $invite->invitee_email );
				bp_update_user_meta( $new_user->ID, 'accepted_members_invitation', $invite->id );

				// We will mark all invitations to this user as "accepted."
				if ( ! empty( $invite->invitee_email )  ) {
					$args  = array(
						'invitee_email' => $invite->invitee_email,
						'item_id'       => get_current_network_id(),
						'type'          => 'all'
					);
					$this->mark_accepted( $args );
				}

				/**
				 * Fires after a user has accepted a site membership invite.
				 *
				 * @since 8.0.0
				 *
				 * @param BP_Invitation $invite     Invitation that was accepted.
				 * @param WP_user       $new_user   ID of the user who accepted the membership invite.
				 * @param int           $inviter_id ID of the user who invited this user to the site.
				 */
				do_action( 'members_invitations_invite_accepted', $invite, $new_user, $invite->inviter_id );
			}
		}

		return true;
	}


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.