0

I'd been working on a module where customer choose at the time of registration for which website he need to register. So far I'd done it working. A quick reference to that. On successful registration the customer is being redirected to customer/account/ in the current website regardless of which website he chosen. But I need him to be redirected to that particular website for which he had registered.

So far I'd tried overriding the Customer/AccountController's _welcomeCustomer():

protected function _welcomeCustomer($customer, $isJustConformed = false) {
    $webid = $customer->getWebsiteId();
    $successurl = parent::_welcomeCustomer($customer, $isJustConfirmed);
    if (Mage::app()->getStore()->getWebsiteId() == $webid) {
        return $successurl;
    } else {
        return Mage::app()->getWebsite($webid)->getDefaultStore()->getBaseUrl() . 'customer/account/index';
    }
} 

But instead of redirecting the customer to associated website it being redirected to home page of the current website. Any help? How could it be done? or this happening so?

2 Answers 2

1

Inside your controller you can set redirect to url

$url = Mage::app()->getWebsite($webid)->getDefaultStore()->getBaseUrl() . 'customer/account/index';
$this->_redirectUrl($url);

Also read this article about login in a magento multiple website setup.

7
  • as I can see in Customer/AccountController's _successProcessRegistration() from where its being called and after that it do redirect as: $url = $this->_welcomeCustomer($customer); $this->_redirectSuccess($url); Commented Feb 14, 2014 at 13:20
  • But $this->_redirectUrl() and $this->_redirectSuccess() are different functions Commented Feb 14, 2014 at 13:22
  • but I tried your solution and still the same thing. should i return this new url or not? Commented Feb 14, 2014 at 13:23
  • I recommend you to rewrite _successProcessRegistration instead of _welcomeCustomer. And run $this->_redirectUrl($url) instead of $this->_redirectSuccess() there. Commented Feb 14, 2014 at 13:26
  • okay.. now its been redirected but its been asked to login. customer must be redirected to his dashboard Commented Feb 14, 2014 at 13:30
0

this auto-login module helped me to achieve what I'm looking for.
Rest of the thing I've done to make it work proper is:

Overridden the Customer/AccountController's _welcomeCustomer()

protected function _welcomeCustomer($customer, $isJustConformed = false) {
    $webid = $customer->getWebsiteId();
    $encpw = ;//get customer password and encrypt it;
    if (Mage::app()->getStore()->getWebsiteId() == $webid) {
        return parent::_welcomeCustomer($customer, $isJustConfirmed);
    } else {
        $redr = Mage::app()->getWebsite($webid)->getDefaultStore()
                        ->getBaseUrl() . 'customer/account/autoLogin/'
                . 'user/' . $customer->getEmail() . '/pwd/' . $encpw .
                '/';
        return $redr;
    }
}

One more thing might needed to be changed in _successProcessRegistration() is to replace $this->_redirectSuccess($url); with $this->_redirectUrl($url); as suggested by oleksii.svarychevskyi here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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