bp_members_invitations_complete_signup( bool|WP_Error $user_id, string $user_login = '', string $user_password = '', string $user_email = '' )

When a user joins the network via an invitation: – mark all invitations and requests as accepted – activate the user upon signup


Parameters Parameters

$user_id

(bool|WP_Error) (Required) True on success, WP_Error on failure.

$user_login

(string) (Optional) Login name requested by the user.

Default value: ''

$user_password

(string) (Optional) Password requested by the user.

Default value: ''

$user_email

(string) (Optional) Email address requested by the user.

Default value: ''


Source Source

File: bp-members/bp-members-invitations.php

function bp_members_invitations_complete_signup( $user_id, $user_login = '', $user_password = '', $user_email = '' ) {
	if ( ! $user_id ) {
		return;
	}

	// Check to see if this signup is the result of a valid invitation.
	$invite = bp_get_members_invitation_from_request();
	if ( ! $invite->id ) {
		return;
	}

	// Accept the invitation.
	$invites_class = new BP_Members_Invitation_Manager();
	$args          = array(
		'id' => $invite->id,
	);
	$invites_class->accept_invitation( $args );

	// User has already verified their email by responding to the invitation, so we can activate.
	$key = bp_get_user_meta( $user_id, 'activation_key', true );
	if ( $key ) {
		/**
		 * Filters the activation signup.
		 *
		 * @since 1.1.0
		 *
		 * @param bool|int $value Value returned by activation.
		 *                        Integer on success, boolean on failure.
		 */
		$user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );

		// If there were errors, add a message and redirect.
		if ( ! empty( $user->errors ) ) {
			bp_core_add_message( $user->get_error_message(), 'error' );
			bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
		}

		bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
		bp_core_redirect( add_query_arg( 'activated', '1', bp_get_activation_page() ) );
	}
}


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.