Automattic\WooCommerce\Blocks\Domain\Services\Email

CustomerNewAccount::trigger()publicWC 1.0

Trigger.

Method of the class: CustomerNewAccount{}

No Hooks.

Return

null. Nothing (null).

Usage

$CustomerNewAccount = new CustomerNewAccount();
$CustomerNewAccount->trigger( $user_id, $user_pass, $password_generated );
$user_id(int) (required)
User ID.
$user_pass(string)
User password.
Default: ''
$password_generated(true|false)
Whether the password was generated automatically or not.
Default: false

CustomerNewAccount::trigger() code WC 8.7.0

public function trigger( $user_id, $user_pass = '', $password_generated = false ) {
	$this->setup_locale();

	if ( $user_id ) {
		$this->object = new \WP_User( $user_id );

		// Generate a magic link so user can set initial password.
		$key = get_password_reset_key( $this->object );
		if ( ! is_wp_error( $key ) ) {
			$action                 = 'newaccount';
			$this->set_password_url = wc_get_account_endpoint_url( 'lost-password' ) . "?action=$action&key=$key&login=" . rawurlencode( $this->object->user_login );
		}

		$this->user_login = stripslashes( $this->object->user_login );
		$this->user_email = stripslashes( $this->object->user_email );
		$this->recipient  = $this->user_email;
	}

	if ( $this->is_enabled() && $this->get_recipient() ) {
		$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments(), $this->set_password_url );
	}

	$this->restore_locale();
}