I need to extend the custom success message after the customer registration. Now after registration the user is redirected to the dashboard and the standard success message is shown: "Thank you for registering with...".
I need that this message changes base on the customer group attribute. I read on-line but didn't find a working solution... but I think I'm making it in the wrong way. I started from here: http://mydons.com/simple-example-using-magento-event-observer/ to make a custom observer on the customer_register_success event, so I made the module xml named Bbox_Regmess.xml in app/etc/modules:
<config>
<modules>
<Bbox_Regmess>
<active>true</active>
<codePool>local</codePool>
</Bbox_Regmess>
</modules>
</config>
Than I made the app/code/local/Bbox/Regmess/etc and app/code/local/Bbox/Regmess/Model folders with inside the config.xml:
<config>
<modules>
<Bbox_Regmess>
<version>0.1.0</version>
</Bbox_Regmess>
</modules>
<frontend>
<events>
<customer_register_success>
<observers>
<Bbox_Regmess_Model_Observer>
<type>singleton</type>
<class>Bbox_Regmess_Model_Observer</class>
<method>Customregmess</method>
</Bbox_Regmess_Model_Observer>
</observers>
</customer_register_success>
</events>
</frontend>
</config>
And the Observer.php that is just a first try to see if I'm able to add a custom success message:
<?php
class Bbox_Regmess_Model_Observer {
public function Customregmess($observer) {
$event = $observer->getEvent(); //Fetches the current event
$customer = $event->getCustomer();
$eventmsg = "Current Event Triggered : <I>" . $event->getName() . "</I><br/> Currently Added Product : <I> " . $customer->getCustomerName()."</I>";
//Adds Custom message to shopping cart
Mage::getSingleton('customer/session')->addSuccess($eventmsg);
}
}
?>
Now if a user registers to the shop, he get the standard registration message and there is not the custom $eventmsg
What I'm making wrong? There is another way to to that? Thanks
UPDATE:
looking deeper I found out the default success message is defined in the app/code/core/Mage/Customer/controllers/AccountController.php at line 390 (just after the line 334 where there is the definition of customer_register_success event I'm trying to work with).
at line 390 there is the _welcomeCustomer function that is in charge of setting the success message, send confirmation email and set the success redirect url:
protected function _welcomeCustomer(Mage_Customer_Model_Customer $customer, $isJustConfirmed = false)
{
$this->_getSession()->addSuccess(
$this->__('Thank you for registering with %s.', Mage::app()->getStore()->getFrontendName())
);
$customer->sendNewAccountEmail(
$isJustConfirmed ? 'confirmed' : 'registered',
'',
Mage::app()->getStore()->getId()
);
$successUrl = Mage::getUrl('*/*/index', array('_secure'=>true));
if ($this->_getSession()->getBeforeAuthUrl()) {
$successUrl = $this->_getSession()->getBeforeAuthUrl(true);
}
return $successUrl;
}
Is there any chance to extend this function so I can manage multiple success message base on the customer group?
I've look for some resource about it, but I didn't find anything usefull