Magento 2.x – How to lock and unlock customers programatically

If you want to lock a customer programatically, you can perform the following steps.

  • You can Lock it directly over the database changing the following fields:
    • Go to customer_entity table.
    • Set failures_num = 10 (something more than 3 which is the max failure number)
    • Set ‘lock_expires’ =  ‘2029-11-06 10:17:50’ (any datetime with something where you know its going to be fair enough, like 10 years later)
    • Go to customer_grid_flat table.
    • Set ‘lock_expires’ as well as on customer_entity table.
  • If you need to perform the same thing programatically, you can use the following snippet:


source link