dispatch custom event in Magento

1. A controller dispathes the event register_success and broadcasts the customer data.

Mage::dispatchEvent('register_success', array('customer' => $customer));

2. The event configuration in the module’s config.xml file. It says run the function processCustomerData in the php class PackageName_ModuleName_Model_Observer when the event register_success is happened.

<frontend>
    <events>
	   	<enroll_success>
	   		<observers>
	   			<register_success_observer>
	   				<type>singleton</type>
	   				<class>PackageName_ModuleName_Model_Observer</class>
	   				<method>processCustomerData</method>
	   			</register_success_observer>
	   		</observers>
	   	</enroll_success>
    </events>
</frontend>

3. The function processCustomerData that reacts to the event ‘register_success

public function processCustomerData(Varien_Event_Observer $observer)
{
   	$event = $observer->getEvent();
	$customer = $event->getCustomer();
	//Do something with the customer data
}

References:
Magento observer examples
Magento native event list

Search within Codexpedia

Custom Search

Search the entire web

Custom Search