1

I'm currently working on a comment system on my product view. The problem I'm trying to solve is redirecting the user back to the comments section in the product view after the user logs in.

I read I can include a /referer/ in the URL of the log in page (for example, /customer/account/login/referer/path/to/product#comments) and that would redirect me back to the URL path I want. I tried this and it doesn't work.

Anyone know how I can go about this? Any help is greatly appreciated.

  • do you want to redirect all logins to this comment page or only the user tried to comment and login? – Mujahidh Apr 29 at 6:04
  • @Mujahidh hi, only the user tried to comment and login. – Brian Moreno Apr 29 at 15:57
  • yes try the answer.hope it will help you – Mujahidh Apr 30 at 5:13
0

Hi use setBeforeAuthUrl method in your code. use below code in the product comment section when requesting the customer login.

if(!Mage::helper('customer')->isLoggedIn()) {
Mage::getSingleton('customer/session')
        ->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl()); 
echo '<p>Please <a href="'.Mage::getUrl('customer/account/login').'">Login</a> to view the page.</p>';
}

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.