WC_Email_Customer_New_Account::generate_set_password_url()protectedWC 6.0.0

Generate set password URL link for a new user.

See also Automattic\WooCommerce\Blocks\Domain\Services\Email\CustomerNewAccount and wp_new_user_notification.

Method of the class: WC_Email_Customer_New_Account{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->generate_set_password_url();

Changelog

Since 6.0.0 Introduced.

WC_Email_Customer_New_Account::generate_set_password_url() code WC 8.7.0

protected function generate_set_password_url() {
	// Generate a magic link so user can set initial password.
	$key = get_password_reset_key( $this->object );
	if ( ! is_wp_error( $key ) ) {
		$action                 = 'newaccount';
		return wc_get_account_endpoint_url( 'lost-password' ) . "?action=$action&key=$key&login=" . rawurlencode( $this->object->user_login );
	} else {
		// Something went wrong while getting the key for new password URL, send customer to the generic password reset.
		return wc_get_account_endpoint_url( 'lost-password' );
	}
}