Skip to main content
added 1111 characters in body
Source Link
Sohel Rana
  • 36.1k
  • 3
  • 73
  • 91

Go to Stores -> Configuration -> Customer Configuration -> Create New Account Options

Now Set Require Emails Confirmation to Yes

Clear cache.

[Update]

Overwrite Magento/Customer/Model/AccountManagement.php class. Modify following method


/**
 * Send either confirmation or welcome email after an account creation
 *
 * @param CustomerInterface $customer
 * @param string $redirectUrl
 * @return void
 */
protected function sendEmailConfirmation(CustomerInterface $customer, $redirectUrl)
{
    try {
        $hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
        $templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED;
        if ($this->isConfirmationRequired($customer) && $hash != '') {
            $templateType = self::NEW_ACCOUNT_EMAIL_CONFIRMATION;
        } elseif ($hash == '') {
            $templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD;
        }
        $this->getEmailNotification()->newAccount($customer, $templateType, $redirectUrl, $customer->getStoreId());
    } catch (MailException $e) {
        // If we are not able to send a new account email, this should be ignored
        $this->logger->critical($e);
    }
}

In your case $hash is empty. So change that logic.

Go to Stores -> Configuration -> Customer Configuration -> Create New Account Options

Now Set Require Emails Confirmation to Yes

Clear cache.

Go to Stores -> Configuration -> Customer Configuration -> Create New Account Options

Now Set Require Emails Confirmation to Yes

Clear cache.

[Update]

Overwrite Magento/Customer/Model/AccountManagement.php class. Modify following method


/**
 * Send either confirmation or welcome email after an account creation
 *
 * @param CustomerInterface $customer
 * @param string $redirectUrl
 * @return void
 */
protected function sendEmailConfirmation(CustomerInterface $customer, $redirectUrl)
{
    try {
        $hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
        $templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED;
        if ($this->isConfirmationRequired($customer) && $hash != '') {
            $templateType = self::NEW_ACCOUNT_EMAIL_CONFIRMATION;
        } elseif ($hash == '') {
            $templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD;
        }
        $this->getEmailNotification()->newAccount($customer, $templateType, $redirectUrl, $customer->getStoreId());
    } catch (MailException $e) {
        // If we are not able to send a new account email, this should be ignored
        $this->logger->critical($e);
    }
}

In your case $hash is empty. So change that logic.

Source Link
Sohel Rana
  • 36.1k
  • 3
  • 73
  • 91

Go to Stores -> Configuration -> Customer Configuration -> Create New Account Options

Now Set Require Emails Confirmation to Yes

Clear cache.