Jump to content

actionCustomerAccountUpdate on update done by admin


Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...