GetSchwifty Posted February 5, 2020 Share Posted February 5, 2020 Hi, I specifically set my shop to create all new users deactivated. Now, I'd like to send custom e-mail to the user, when an admin manualy activates him/her in the backoffice. I know, that there's an actionCustomerAccountUpdate hook, however this hooks is only called when user updates his own information, not when admin does this. How to do this? Thank you. Link to comment Share on other sites More sharing options...
fbenoist.com Posted February 5, 2020 Share Posted February 5, 2020 You can use the hook actionObjectCustomerUpdateAfter public function hookactionObjectCustomerUpdateAfter($params) { $id_customer = (int)$params['object']->id; // ... } Link to comment Share on other sites More sharing options...
GetSchwifty Posted February 6, 2020 Author Share Posted February 6, 2020 13 hours ago, fbenoist.com said: You can use the hook actionObjectCustomerUpdateAfter public function hookactionObjectCustomerUpdateAfter($params) { $id_customer = (int)$params['object']->id; // ... } Thank you! However it seems like this hook fires too late. When I get the Customer object from actionObjectCustomerUpdateAfter or actionObjectCustomerUpdateBefore, it's already changed. In other words - if I want to activate deactivated user, the actionObjectCustomerUpdateBefore hook returns user that is already active. How come? Link to comment Share on other sites More sharing options...
fbenoist.com Posted February 6, 2020 Share Posted February 6, 2020 I guess you're right, the value of active is modified before calling the update() function. You can use actionObjectCustomerUpdateBefore and reload Customer from database public function hookactionObjectCustomerUpdateBefore($params) { $id_customer = (int)$params['object']->id; $customerInDb = new Customer($id_customer); if ($params['object']->active != $customerInDb->active) { // Active change... } } Link to comment Share on other sites More sharing options...
GetSchwifty Posted February 7, 2020 Author Share Posted February 7, 2020 Fantastic! Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now