Hi I referred this solution for disabling welcome email and it works perfectly.however i want the around plugin to work only if its enabled from admin backend that too in store basis.

I added etc/adminhtml/system.xml

<?xml version="1.0" ?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
        <section id="customer" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
            <group id="create_account" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                <field id="welcome_email_disable" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Disable Welcome Email</label>


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">


<?xml version="1.0" encoding="utf-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    <type name="\Magento\Customer\Model\EmailNotification">
        <plugin name="disable-email-notification" type="Vendor\moduleName\Plugin\EmailNotification" sortOrder="1"/>





namespace Vendor\moduleName\Helper;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Helper\AbstractHelper;

class Data extends AbstractHelper
    protected $scopeConfig;

     * Extension enabled config path
    protected const XML_PATH_NO_WELCOME_EMAIL = 'customer/create_account/welcome_email_disable';

     * Constructor
     * @param ScopeConfigInterface $scopeConfig
    public function __construct(
        ScopeConfigInterface $scopeConfig
    ) {
        $this->scopeConfig = $scopeConfig;
     * Retrieve true if extension is enabled.
     * @return bool
    public function moduleEnabled()
        return (bool) $this->scopeConfig->getValue(



namespace Vendor\moduleName\Plugin;
use Vendor\moduleName\Helper\Data;
class EmailNotification
    public function __construct(
        Data $moduleEnable
    ) {
        $this->moduleEnable = $moduleEnable;

        public function aroundNewAccount(\Magento\Customer\Model\EmailNotification $subject, \Closure $proceed)
             if ($this->moduleEnable->moduleEnabled() ===  1) {
                return $subject;

even though i am getting the value from moduleEnabled() in EmailNotification.php, this is not working properly and new customers created through admin are not visible when trying this code out.Could anyone help me with this ? I needed to enable/disable this feature from backend admin configuration in store basis.

1 Answer 1


This is I think due to a php error

=== operator makes a strict comparison type.

so what is happening is that you make

true === 1 // false
true == 1 // true

So either you compare with the value true, either you remove the bool cast from your method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.