Magento – Customer login redirect to homepage

customermagento-1.9.2.1

When I'm logging that time it redirects to the homepage but I don't want this.

I want to redirect that page in My account dashboard page.

In configuration
System > Config > Customer > Customer Configuration > Login option > Redirect Customer to Account Dashboard after Logging is
set as Yes. It is set to yes on all scopes

I don't know why this redirect to the homepage.

How to redirect page to my account.

How can I do this?

Best Answer

You have to rewrite in local loginPostAction() from app/code/core/Mage/Customer/controllers/AccountController.php to app/code/local/Customer/controllers/AccountController.php Then you put this :

 public function loginPostAction(){

    if (!$this->_validateFormKey()) {
        $this->_redirect('*/*/');
        return;
    }

    if ($this->_getSession()->isLoggedIn()) {
        $this->_redirect('wlc_business');
        return;
    }
    $session = $this->_getSession();

    if ($this->getRequest()->isPost()) {
        $login = $this->getRequest()->getPost('login');
        if (!empty($login['username']) && !empty($login['password'])) {
            try {
                $session->login($login['username'], $login['password']);
                if ($session->getCustomer()->getIsJustConfirmed()) {
                    $this->_welcomeCustomer($session->getCustomer(), true);
                }
            } catch (Mage_Core_Exception $e) {
                switch ($e->getCode()) {
                    case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
                        $value = $this->_getHelper('customer')->getEmailConfirmationUrl($login['username']);
                        $message = $this->_getHelper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
                        break;
                    case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
                        $message = $e->getMessage();
                        break;
                    default:
                        $message = $e->getMessage();
                }
                $session->addError($message);
                $session->setUsername($login['username']);
            } catch (Exception $e) {
                // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
            }
        } else {
            $session->addError($this->__('Login and password are required.'));
        }
    }

    // The adding code here
    $this->_redirectReferer(); //redirect you to the previous page
    $this->_redirect('/'); // redirect you to the home page
    $this->_redirect('wishlist'); //redirect you to wishlist page for exemple
}