A simple Magento 2 extension that prevents customer from changing account email address. Suitable for many business environments such as B2B. It is also useful when you have an integration that the account email is used as an identifier in the other systems.
- Disables/Enables customer's ability to change account email
- Prevents a hack that can resulting in sending "Email Change Notification" email even the account email is not changed and unintentional logout
- Works for both Frontend and WebAPI area
This extension does not use preference
and template override
.
*Note: this extension disables the change email checkbox
in frontend customer account editing page. If you are looking for a better UI experience such as removing the change email checkbox
or the email input box, you may need to do a theme customization for Magento_Customer::form/edit.phtml
template.
Magento 2.4
composer require wubinworks/module-disable-change-email
Admin Panel Stores > Configuration > Customers > Customer Configuration > Account Information Options
.
Disable Change Email
: Yes/No
If you want to change customer email programmatically in Customer User Context
(e.g., in your frontend controller), use \Magento\Customer\Model\Customer
instead of \Magento\Customer\Api\CustomerRepositoryInterface
. See example.
If you like this extension please star this repository.
You may also like: Disable Customer for Magento 2