cancel
Showing results for 
Search instead for 
Did you mean: 

Disable Welcome Email after registration

Disable Welcome Email after registration

I would like to stop the "Welcome" Email that is sent after registration in Magento 2.4.3 (Open Source). Unfortunately I could not find a switchable option in the backend and the instructions referenced in this post do not work in my 2.4.3-p3 instance.

Does anyone have any advice for me on how to get there?

6 REPLIES 6

Re: Disable Welcome Email after registration

Hi @kempermusic 

 

Could you post the code here so that it is clear what have you tried till now? This will make easy to to help.

 

Thanks

---
Problem Solved Click Accept as Solution!:Magento Community India Forum

Re: Disable Welcome Email after registration

Hi @Mukesh Tiwari,

i initially used the code from the forum post that i linked (see above). After having no success with it, I modified the code as follows (derived from the Dotdigital module that also uses aroundNewAccount):

/app/code/<Vendor>/DisableWelcomeEmail/etc/di.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Customer\Model\EmailNotificationInterface">
        <plugin name="disable_welcome_email" sortOrder="1"
                type="<Vendor>\DisableWelcomeEmail\Plugin\CustomerEmailNotificationPlugin" />
    </type>
</config>

/app/code/<Vendor>/DisableWelcomeEmail/Plugin/CustomerEmailNotificationPlugin.php:

<?php
namespace <Vendor>\DisableWelcomeEmail\Plugin;
class CustomerEmailNotificationPlugin
{
    public function aroundNewAccount(
        \Magento\Customer\Model\EmailNotificationInterface $emailNotification,
        callable $proceed,
        \Magento\Customer\Api\Data\CustomerInterface $customer,
                                                           $type = \Magento\Customer\Model\EmailNotificationInterface::NEW_ACCOUNT_EMAIL_REGISTERED,
                                                           $backUrl = '',
                                                           $storeId = 0,
                                                           $sendemailStoreId = null
    ) {
        return ;
    }
}

This is the latest state, but it doesn't have the intended effect either.

Re: Disable Welcome Email after registration

Hello @kempermusic 

 

Kindly follow below link:
Disable welcome email

Problem solved? Click Accept as Solution!

Re: Disable Welcome Email after registration

Hi @Bhanu Periwal,

thank you for your answer, but this -disabling welcome email for one specific store view- is not, what I´m trying to achieve.

At the moment, this iss what I have:

  1. I created the class EmailNotification in the file /app/code/<Vendor>/DisableWelcomeEmail/Plugin/EmailNotification.php
  2. I created the file app/code/<Vendor>/DisableWelcomeEmail/etc/di.xml

    EmailNotification.php:

    <?php
    namespace <Vendor>\DisableWelcomeEmail\Plugin;
    class EmailNotification {
        public function aroundNewAccount (
            \Magento\Customer\Model\EmailNotification $subject,
            \Closure $proceed
        ): \Magento\Customer\Model\EmailNotification
        {
            return $subject;
        }
    }

    di.xml:

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <type name="Magento\Customer\Model\EmailNotification">
            <plugin name="disable_welcome_email" sortOrder="1"
                    type="<Vendor>\DisableWelcomeEmail\Plugin\EmailNotification" />
        </type>
    </config>

    ... but unfortunately the "Welcome"-Email is is sent anyway. Is there anything else I need to do? Are there any errors in the code or in the file structure?

Re: Disable Welcome Email after registration

Hello @kempermusic 

 

Kindly refer below code:

class CustomerEmailNotificationPlugin
{
    public function aroundNewAccount(
        \Magento\Customer\Model\EmailNotificationInterface $emailNotification,
        callable $proceed,
        \Magento\Customer\Api\Data\CustomerInterface $customer,
                                                           $type = \Magento\Customer\Model\EmailNotificationInterface::NEW_ACCOUNT_EMAIL_REGISTERED,
                                                           $backUrl = '',
                                                           $storeId = 0,
                                                           $sendemailStoreId = null
    ) {
        return ;
    }
}
Problem solved? Click Accept as Solution!

Re: Disable Welcome Email after registration

Hi @Bhanu Periwal ,
thank you, but unfortunately that does not work either.
How can I make sure that the class is loaded at all? Or, rather: how can I check if I made a mistake when including the plugin (e.g. wrong path, error in the XML)?
I am grateful for any advice!