Jump to content

[Solved] Send User An Email After Account Activation


AnilaN

Recommended Posts

Hi,

I've disabled client activation after registration and it'll be done by the admin afterwards. Now I want to send the client an email when their account is activated.

I'm using Prestashop 1.5.3 and I'm a little lost as I recently updated it from 1.4.8. Can someone just point me to the right direction i.e which file to modify. I've looked into AdminCustomerController.php but can't find what exactly should i modify.

Thanks in advance

Aany

[EDIT] For those who are interested, here's the link to the module I created for this function.
http://www.prestashop.com/forums/topic/243669-module-send-email-to-client-after-manual-account-activation/page__p__1206232?do=findComment&comment=1206232

Edited by AnilaN (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

Why would you like to change core Prestashop classes to do this? I strongly advise you to stay away from any Prestashop core classes modification as this will hypothetically break when you perform any update. I would in fact, advise you to create a new module called i.e. "My Custom Stuffs" where you will be implementing some hooks for some operations you are trying to achieve.

 

Prestashop 1.5 defines new action hooks you can use to perform this task (please refer to documentation and especially on the admin hooks here: http://doc.prestashop.com/display/PS15/New+Developers+Features+In+PrestaShop+1.5

 

Indeed, the hook you are after could typically be the one named actionObjectCustomerUpdateAfter. This hook will automatically be called by Prestashop (through the ObjectModel) whenever there is a row or batch of rows update on the customer table (considering we speak a bout the Customer controller). If you change account activation through the BO then this will translate automatically in an update of that customer row in the database (the Customer table). Hence, there will be, through the ObjectModel a call to any hooks attached to any update on this Customer table.

 

Therefore, you can do:

 

1 - Create a very simple module "My Custom Stuffs"

2 - Register the hook actionObjectCustomerUpdateAfter with this module in the install() method.

3 - Define a public function called hookActionObjectCustomerUdpateAfter, typically public function hookActionObjectCustomerUpdateAfter($params)

4 - In that method, check the activation flag (through the $params array) and call Mail::send() whenever this flag has been set to active. (please read specs of Mail class).

 

It might sound painful, but it's only very few line of codes... However, it has a dramatic advantage: you don't touched anything from Prestashop core classes and any update replacing this AdminCustomerController will not require anything changed and your initial functionality will still be working smoothly.

 

Hope this helps!

 

BR,

RaPhiuS

Edited by RaPhiuS (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Thanks RaPhiuS. Yours is indeed a safe solution. Even though I acheived what I wanted by modifying AdminCustomerController, I'll surely try your solution which (if I succeeeded) will be great.

thanks once again.

Aany

Link to comment
Share on other sites

For those who'll be interested, i've created a module for this functionality (compatible for prestashop 1.5). I'm testing it right now and if someone wants it I can send it once i've finished the tests.

thanks once again to Raphius for giving me directions that helped me a lot.

Link to comment
Share on other sites

For those who'll be interested, i've created a module for this functionality (compatible for prestashop 1.5). I'm testing it right now and if someone wants it I can send it once i've finished the tests.

thanks once again to Raphius for giving me directions that helped me a lot.

 

Hi aany,

 

I would like to have this module please if it is not a problem. Thanks a lot!

 

Jambo

Link to comment
Share on other sites

Hi cyjambo

here's the link to my repository, you can download it from there.

 

https://github.com/anila-niaz/Prestashop/tree/master/Modules

 

Please note that it works if you change client status from the edit page and then save it. My next task is to notify client when their account is activated from the user list.

 

Normally it should work, i've conducted the necessary tests, but if you see a problem please do not hesitate to contact me.

 

Aany

  • Like 3
Link to comment
Share on other sites

  • 4 weeks later...

Hi cyjambo

here's the link to my repository, you can download it from there.

 

https://github.com/a.../master/Modules

 

Please note that it works if you change client status from the edit page and then save it. My next task is to notify client when their account is activated from the user list.

 

Normally it should work, i've conducted the necessary tests, but if you see a problem please do not hesitate to contact me.

 

Aany

 

Is it okey if I use your code in one of my modules?

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...