The Home for Magento 2 Excellence

Quality-tested Magento 2 modules. Explore. Evaluate. Elevate. #magento2

1090 Modules
617 Ready
473 Need Help
🏆 Leaderboard
Stable v1.1.1

Block Customer Login for Magento 2

warleyelias/customer-login

Adds a Blocked customer attribute that, when set, prevents the customer from logging in and shows a configurable account-blocked message, giving store admins backend control to lock individual accounts.

274
Downloads
Below average
0
GitHub Stars
10mo ago
Last Release
0
Open Issues
Build Issues
2/3 checks passed

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
1 error , 70 warnings
PHPStan Failed

Tested on Magento 2.4.9

Recent Test History

Each release is tested against the latest Magento version at that time.

v1.1.1 on Magento 2.4.9
Jun 2, 2026

Looking for Contributors

Dependency injection compilation fails. Your contribution could help the entire Magento community!

Contribute

Share This Module's Status

Block Customer Login for Magento 2 Magento compatibility status badge

README

Loaded from GitHub

How to lock a customer account in magento 2

  • When you work on a project, the client requires you to block a customer account from the backend, the client means preventing them from using their account. Then the customer can't be able to log in to their account. By default, Magento hasn't this functionality. You don't know how to complete this task, you are searching for a good solution. Today I show you the best codes to complete your task.

  • We have the scenario: We will create a new customer attribute called "Blocked", it will have two options (Yes/No). If this attribute is set to "Yes" when a customer tries to log in, they will get an inform similar to this "Your account is blocked for the security reason, please contact us for details."

Screenshot

See the video How to lock a customer account in magento 2 here.

https://www.youtube.com/watch?v=tBGagDLXUAQ&list=PL98CDCbI3TNvPczWSOnpaMoyxVISLVzYQ

How to add a new dynamic row system configuration in the Magento 2 admin.

https://www.youtube.com/watch?v=GZ-I9SdGLT0&list=PL98CDCbI3TNvPczWSOnpaMoyxVISLVzYQ

After instalation execute the query to change the source model to your attribute

UPDATE `eav_attribute` SET `source_model` = 'PHPCuong\\CustomerLogin\\Model\\Customer\\Attribute\\Source\\Reason' WHERE `eav_attribute`.`attribute_code` = 'reason'; This is to not impact when you generate an image that is direct connect to your production BD, so after deploy you need to change the source_model for attribute reason

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.