WC_Email_Customer_New_Account::generate_set_password_urlprotectedWC 6.0.0

Generate set password URL link for a new user.

Method of the class: WC_Email_Customer_New_Account{}

No Hooks.

Returns

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 10.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 ) ) {
		// 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' );
	}

	return sprintf( '%s?action=newaccount&key=%s&login=%s', wc_get_account_endpoint_url( 'lost-password' ), $key, rawurlencode( $this->object->user_login ) );
}