If you want to check that the customer is new or not than you need to create custom customer attribute named "is_new".
Use this extension: https://www.magentocommerce.com/magento-connect/manage-customer-attributes-1.html
Create observer for customer_save_after and customer_register_success.
<global>
<events>
<customer_save_after>
<observers>
<namespace_module>
<type>singleton</type>
<class>namespace_module/observer</class>
<method>doSomething</method>
</namespace_module>
</observers>
</customer_save_after>
<customer_register_success>
<observers>
<namespace_module>
<type>singleton</type>
<class>namespace_module/observer</class>
<method>doSomething</method>
</namespace_module>
</observers>
</customer_register_success>
</events>
</global>
Create Oberver.php
class [Namespace]_[Module]_Model_Observer
{
protected $canDoSomething = false;
public function doSomething($observer)
{
if (!$this->canDoSomething) {
//here your code
//set is_new = 1 here
//now set flag to true to prevent executing your code twice
$this->canDoSomething = true;
}
}
}
Overrides the _loginPostRedirect method of default AccountController to redirect on custom URL.
require_once 'Mage/Customer/controllers/AccountController.php';
class MagentoPycho_Customer_AccountController extends Mage_Customer_AccountController
{
/**
* Overriding defaults redirect URL
* Define target URL and redirect customer after logging in
*/
protected function _loginPostRedirect()
{
$session = $this->_getSession();
// $is_new = get customer data and check for is_new attribute value.
if($is_new == 1){
// redirect to your custom module
// set is_new attribute value to 0.
}else{
if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl() ) {
// Set default URL to redirect customer to
$session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
// Redirect customer to the last page visited after logging in
if ($session->isLoggedIn())
{
if (!Mage::getStoreConfigFlag('customer/startup/redirect_dashboard')) {
if ($referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME)) {
$referer = Mage::helper('core')->urlDecode($referer);
if ($this->_isUrlInternal($referer)) {
$session->setBeforeAuthUrl($referer);
}
}
}
} else {
$session->setBeforeAuthUrl(Mage::helper('customer')->getLoginUrl());
}
}
}
$this->_redirectUrl($session->getBeforeAuthUrl(true));
}
}
Now this code will check if the customer is new than it will redirect to your module else default behaviour