This can be done perfectly with the Magento event / observer system. First of all, register your module.
applications / etc / modules / Namespace_Modulename.xml
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Namespace_Modulename> <active>true</active> <codePool>local</codePool> </Namespace_Modulename> </modules> </config>
Write the configuration file for it.
Application / code / local / namespace / MODULENAME / etc. /config.xml
<?xml version="1.0"?> <config> <modules> <Namespace_Modulename> <version>0.0.1</version> </Namespace_Modulename> </modules> <frontend> <events> <customer_register_success> <observers> <unic_observer_name> <type>model</type> <class>unic_class_group_name/observer</class> <method>customerRegisterSuccess</method> </unic_observer_name> </observers> </customer_register_success> </events> <helpers> <unic_class_group_name> <class>Namespace_Modulename_Helper</class> </unic_class_group_name> </helpers> </frontend> <global> <models> <unic_class_group_name> <class>Namespace_Modulename_Model</class> </unic_class_group_name> </models> <template> <email> <notify_new_customer module="Namespace_Modulename"> <label>Template to notify administrator that new customer is registered</label> <file>notify_new_customer.html</file> <type>html</type> </notify_new_customer> </email> </template> </global> </config>
Here are a few things:
- A new observer was registered to trigger the
customer_register_success event (it was sent on line 335 in the Mage_Customer_AccountController ) in the frontend/events node. This is better than using customer_save_after , since the latter will fire every time a client is saved, and not just when it is registered; - A new email template has been registered in
global/template/email node. To allow us to send a special email with him.
Next, create an email template (file).
application / locale / en_US / template / notify_new_customer.html
Congratulations, a new customer has been registered:<br /> Name: {{var name}}<br /> Email: {{var email}}<br /> ...<br />
Then determine the observer method.
Application / code / local / namespace / MODULENAME / model / Observer.php
class Namespace_Modulename_Model_Observer { public function customerRegisterSuccess(Varien_Event_Observer $observer) { $emailTemplate = Mage::getModel('core/email_template') ->loadDefault('notify_new_customer'); $emailTemplate ->setSenderName(Mage::getStoreConfig('trans_email/ident_support/name')) ->setSenderEmail(Mage::getStoreConfig('trans_email/ident_support/email')) ->setTemplateSubject('New customer registered'); $result = $emailTemplate->send(Mage::getStoreConfig('trans_email/ident_general/email'),(Mage::getStoreConfig('trans_email/ident_general/name'), $observer->getCustomer()->getData()); } }
EDIT: because @benmarks indicated that this solution will not work if the client is registered during the validation. A solution to this behavior is described here . But, I think it is better to use the _origData functionality as suggested by @benmarks. Therefore, use it as a guide to achieve what you need.
Useful links: