shniurs Posted January 3, 2014 Share Posted January 3, 2014 (edited) I need to redirect user to the same page where he filled log-in details. I have a custom pop-up login form which posts to mywebsite.com/login page (the login form can be accessed in any page). The problem is that when I use ?back=mypage in form post url, user is still redirected to my-acount. I found that these values are set in AuthController.php in this line: if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) Tools::redirect(html_entity_decode($back)); Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account')); It seems that posting to url with ?back=ur_to_redirect should work.I also tried to create an input field (name=back) with url in value, but it didn't worked as well. I use PrestaShop 1.5.6.1 Any thoughts how can I get user redirect to previous page after login? Edited January 3, 2014 by shniurs (see edit history) Link to comment Share on other sites More sharing options...
shniurs Posted January 3, 2014 Author Share Posted January 3, 2014 Been looking for the solution whole day, after I posted this post it took me few minutes to figure this out. The solution: find this code in AuthController.php if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) Tools::redirect(html_entity_decode($back)); Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account')); Replace it with this code: if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) Tools::redirect(html_entity_decode($back)); Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL); It will redirect you to the same page where login form was submitted. 1 Link to comment Share on other sites More sharing options...
vekia Posted January 4, 2014 Share Posted January 4, 2014 in addition, simple template change: http://www.prestashop.com/forums/topic/266211-solved-redirect-to-last-page-after-login-15/ Link to comment Share on other sites More sharing options...
Recommended Posts