Mohammad Faisal Mohammad Faisal - 1 year ago 70
PHP Question

redirect customer to associated website on successful registration

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

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

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?

Answer Source

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);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download