0

I'm using below function for redirection after FB login, But it's redirecting to Customers Account Dashboard, Instead of Account Dashboard I'd like to redirect to Home Page or the Previous Page.

 protected function _loginPostRedirect()
 {
    $session = Mage::getSingleton('customer/session');

    if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) {
        // Set default URL to redirect customer to
        $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());

    } else if ($session->getBeforeAuthUrl() == Mage::helper('customer')->getLogoutUrl()) {
        $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
    } else {
        if (!$session->getAfterAuthUrl()) {
            $session->setAfterAuthUrl($session->getBeforeAuthUrl());
        }
        if ($session->isLoggedIn()) {
            $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
        }
    }
    $this->_redirectUrl($session->getBeforeAuthUrl(true));
}

I've tried

$session->setBeforeAuthUrl(Mage::helper('customer')->getHomeUrl());

$session->setBeforeAuthUrl(Mage::helper('customer')->getCurrentUrl());

But it's not working

1

Try Using this to redirect to home page

$homeUrl = Mage::getBaseUrl();
$this->_redirectUrl($homeUrl);

To redirect to Previous page

$this_redirectReferer($defaultUrl=null);
1

to redirect to home url try to use Url Helper instead of Customer Helper
Mage::helper('url')->getHomeUrl(); @see Mage_Core_Helper_Url::getHomeUrl()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.