I would like to be able to run some functionality with a module
that I am building whenever a customer registers
an account, but I can\'t seem to f
customer_register_success
adminhtml_customer_save_after
these two are the default events when a customer is inserted into the database.... first event fires in frontend when a user registers and second event fires in the backend when a customer is created through admin panel...i hope you know how to register an observer for an event...hope this will help you...
customer_register_success is what you are looking for:
<config>
<frontend>
<events>
<customer_register_success>
<observers>
<your_module>
<type>singleton</type>
<class>your_module/observer</class>
<method>yourMethod</method>
</your_module>
</observers>
</customer_register_success>
</events>
</frontend>
</config>
Actually there are customer_save_after
and customer_save_before
(magento 1.5)
If you want to modify on-the-fly some data after form post, pick customer_save_before
, change the data you want and that's all (the save action come after, so your change will be taken into account).
$customer->save()
just doesn't work in customer_save_after
. (fatal error) Use this observer to run a code after customer creation which are NOT related to customer data.
Hope that helps!
I've discovered that the customer_login
and customer_session_init
events are both thrown on account create. You could register a listener for either and then check to see the create date on the account?
You have to consider also when the user register on-the-fly on checkout: a Register on chekout. Thinking on this case, you can catch the "checkout_type_onepage_save_order_after" event with your own Observer class, and then this code...
if($observer->getEvent()->getQuote()->getCheckoutMethod(true) == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER){
(...)
}
Anybody may say: Mage_Sales_Model_Quote->getCheckoutMethod() is deprecated since 1.4!!,but:
if ($this->getCustomerSession()->isLoggedIn()) {
return self::METHOD_CUSTOMER;
}
... "METHOD_CUSTOMER" is the name for a checkout with an already registrated user, not our case.... but yes!, because....
Any other idea for the registration on checkout?