dellwen!!@@ Posted July 31, 2017 Share Posted July 31, 2017 I would like to be able to redirect customers to the home page after login, instead of going to the my-account page. This forum post talks about that, but, it doesn't work in Prestatshop 1.7. Forum post: https://www.prestashop.com/forums/topic/266211-solved-redirect-to-last-page-after-login-15/ Thanks. Link to comment Share on other sites More sharing options...
hardstonepaul Posted November 21, 2017 Share Posted November 21, 2017 Hello use 1.7.1.2 I solved this. I spend many time searching but nothing after all I found a answer Go to: modules\ps_customersignin\ps_customersignin.php , after line 76 'my_account_url' => $link->getPageLink('my-account', true), I create new url variable 'login_url' => $link->getPageLink('authentication', true), Go to: themes\yourtheme\modules\ps_customersignin\ps_customersignin.tpl change this: <a href="{$my_account_url}" title="{l s='Log in to your customer account' d='Shop.Theme.Customeraccount'}" rel="nofollow" > for this with new variable <a href="{$login_url}" title="{l s='Log in to your customer account' d='Shop.Theme.Customeraccount'}" rel="nofollow" > This is all!! Explanation: When we are in 'authentication' after login by default redirect to 'base_url' but when we are in 'my-account' the link have a parameter ...?back=my-account. I hope that this solution can apply for you. I only modified a module customersignin. Maybe in next time someone can fin the way to change the parameter in the ?back. Regards from Colombia. 1 3 Link to comment Share on other sites More sharing options...
rmiho Posted January 13, 2019 Share Posted January 13, 2019 after spending few days managed to redirect to address page as soon as new user register. Link to comment Share on other sites More sharing options...
stevent Posted April 25, 2019 Share Posted April 25, 2019 Does'nt work. Other real solution ? Thanks Link to comment Share on other sites More sharing options...
Henrik41 Posted August 16, 2019 Share Posted August 16, 2019 This solution did not work for me. Link to comment Share on other sites More sharing options...
rmiho Posted August 18, 2019 Share Posted August 18, 2019 check out below thread https://www.prestashop.com/forums/topic/272089-redirect-to-internal-link/?tab=comments#comment-3049983 Link to comment Share on other sites More sharing options...
Henrik41 Posted August 19, 2019 Share Posted August 19, 2019 Thanks! Link to comment Share on other sites More sharing options...
Maryando Posted March 4, 2020 Share Posted March 4, 2020 (edited) On 11/21/2017 at 1:14 AM, hardstonepaul said: Hello use 1.7.1.2 I solved this. I spend many time searching but nothing after all I found a answer Go to: modules\ps_customersignin\ps_customersignin.php , after line 76 'my_account_url' => $link->getPageLink('my-account', true), I create new url variable 'login_url' => $link->getPageLink('authentication', true), Go to: themes\yourtheme\modules\ps_customersignin\ps_customersignin.tpl change this: <a href="{$my_account_url}" title="{l s='Log in to your customer account' d='Shop.Theme.Customeraccount'}" rel="nofollow" > for this with new variable <a href="{$login_url}" title="{l s='Log in to your customer account' d='Shop.Theme.Customeraccount'}" rel="nofollow" > This is all!! Explanation: When we are in 'authentication' after login by default redirect to 'base_url' but when we are in 'my-account' the link have a parameter ...?back=my-account. I hope that this solution can apply for you. I only modified a module customersignin. Maybe in next time someone can fin the way to change the parameter in the ?back. Regards from Colombia. This solution works perfectly if applied correctly even today on Prestashop 1.7.6.2. Thanks a lot! Edited March 18, 2020 by Maryando Mistake (see edit history) 1 Link to comment Share on other sites More sharing options...
loza Posted March 13, 2020 Share Posted March 13, 2020 Hi! after a long search i found a possible solution for prestashop 1.7.3. Go to /controllers/front/AuthController.php find the next code: if (Tools::isSubmit('submitLogin')) { if ($login_form->submit()) { $should_redirect = true; } } commet the line $should_redirect = true; and add a Tools::redirectLink. Finally result: if (Tools::isSubmit('submitLogin')) { if ($login_form->submit()) { // $should_redirect = true; Tools::redirectLink(__PS_BASE_URI__); } } __PS_BASE_URI__ i use this for redirecct to home. Save, upload the php to your server, clean cache from BO Advanced parameters > performance and thats all, after user log redirecct to home. Sorry for my english 2 1 Link to comment Share on other sites More sharing options...
Maryando Posted March 18, 2020 Share Posted March 18, 2020 (edited) Thanks for sharing. Edited March 18, 2020 by Maryando (see edit history) Link to comment Share on other sites More sharing options...
Alex Weiss Posted April 28, 2020 Share Posted April 28, 2020 On 13/03/2020 at 08:02, loza said: Oi! após uma longa pesquisa, encontrei uma possível solução para o prestashop 1.7.3. Vá para /controllers/front/AuthController.php encontre o próximo código: if (Tools :: isSubmit ('submitLogin')) { if ($ login_form-> submit ()) { $ should_redirect = true; } } confirmar a linha $ should_redirect = true; e adicione um Tools :: redirectLink. Finalmente resultado: if (Tools :: isSubmit ('submitLogin')) { if ($ login_form-> submit ()) { // $ should_redirect = true; Ferramentas :: redirectLink (__ PS_BASE_URI__); } } __PS_BASE_URI__ eu uso isso para redirecionar para casa. Salve, envie o php para o servidor, limpe o cache do BO Advanced Parameters> performance e isso é tudo, após o log do usuário redirecionar para casa. Desculpe pelo meu Inglês hello i need to redirect to (my address) after the customer registration, what is the way to change? can you help me? thank you att: Alex Weiss Prestashop 1.7.6.1 https://www.shoppingdoestudante.com/ Link to comment Share on other sites More sharing options...
Pssuido Posted May 26, 2021 Share Posted May 26, 2021 Hello, I have Prestashop 1.7.7.4 and i found on web this solution that works form me If You want to redirect people to index or other pages after login in prestashop 1.7 go to: classes/form/CustomerLoginForm.php Find this line: Hook::exec('actionAuthentication', ['customer' => $this->context->customer]); Replace to this: Tools::redirect('index.php'); Link to comment Share on other sites More sharing options...
w3bsolutions Posted May 26, 2021 Share Posted May 26, 2021 (edited) 5 hours ago, Pssuido said: If You want to redirect people to index or other pages after login in prestashop 1.7 go to: classes/form/CustomerLoginForm.php Find this line: Hook::exec('actionAuthentication', ['customer' => $this->context->customer]); Replace to this: Tools::redirect('index.php'); Do that and you will lose the change every time you upgrade Prestashop. Do it with a proper override, or waayyy better, with a module hooked on actionAuthentication that does the redirection for you and you will be able to upgrade Prestashop happily. Edited May 26, 2021 by w3bsolutions (see edit history) Link to comment Share on other sites More sharing options...
Nickz Posted May 26, 2021 Share Posted May 26, 2021 3 hours ago, w3bsolutions said: Do that and you will lose the change every time you upgrade Prestashop. Changing one line of code does not sound too tedious to me Link to comment Share on other sites More sharing options...
w3bsolutions Posted May 26, 2021 Share Posted May 26, 2021 1 minute ago, Nickz said: Changing one line of code does not sound too tedious to me And how about changing 0 lines of code? Link to comment Share on other sites More sharing options...
Nickz Posted May 26, 2021 Share Posted May 26, 2021 12 minutes ago, w3bsolutions said: And how about changing 0 lines of code? Even better. Just explain in layman terms how and where to change what. Link to comment Share on other sites More sharing options...
w3bsolutions Posted May 26, 2021 Share Posted May 26, 2021 3 hours ago, Nickz said: Even better. Just explain in layman terms how and where to change what. I’ll send you tomorrow Link to comment Share on other sites More sharing options...
w3bsolutions Posted May 27, 2021 Share Posted May 27, 2021 On 5/26/2021 at 9:19 PM, Nickz said: Even better. Just explain in layman terms how and where to change what. As promised, attached is a simple module I did to redirect the customer to any page after logging in. Just put the URL you want to redirect to in the module settings: It can be relative, as in your case for the homepage: index.php Or it can be absolute, any URL such as : https://www.google.com You can undo your change to the core class and it will still work w3b_redirectonlogin.zip 1 3 Link to comment Share on other sites More sharing options...
Nickz Posted May 27, 2021 Share Posted May 27, 2021 thx great just as note it was not for me but for people reading and having a similar issue as the TO Link to comment Share on other sites More sharing options...
Marwa Abdelkader Posted June 28, 2021 Share Posted June 28, 2021 (edited) Le 27/05/2021 à 23h37, w3bsolutions a déclaré : Comme promis, ci-joint un module simple que j'ai fait pour rediriger le client vers n'importe quelle page après s'être connecté. Il suffit de mettre l'URL vers laquelle vous souhaitez rediriger dans les paramètres du module : Il peut être relatif, comme dans votre cas pour la page d'accueil : index.php Ou il peut être absolu, n'importe quelle URL telle que : https://www.google.com Vous pouvez annuler votre modification de la classe de base et cela fonctionnera toujours w3b_redirectonlogin.zip 7,95 Ko · 8 téléchargements Si vous plait Comment rediriger au page précédente aprés connecté au compte !? Edited June 28, 2021 by Marwa Abdelkader (see edit history) Link to comment Share on other sites More sharing options...
Marwa Abdelkader Posted June 28, 2021 Share Posted June 28, 2021 Si vous plait Commentaire rediriger au page précédente aprés connecté au compte !? On 27/05/2021 at 23:37, w3bsolutions said: Comme promis, ci-joint un module simple que j'ai fait pour rediriger le client vers n'importe quelle page après s'être connecté. Il suffit de mettre l'URL vers laquelle vous souhaitez rediriger dans les paramètres du module : Il peut être relatif, comme dans votre cas pour la page d'accueil : index.php Ou il peut être absolu, n'importe quelle URL telle que : https://www.google.com Vous pouvez annuler votre modification de la classe de base et cela fonctionnera toujours w3b_redirectonlogin.zip 7,95 Ko · 8 téléchargements Si vous plait Comment rediriger au page précédente aprés connecté au compte !? Link to comment Share on other sites More sharing options...
Marwa Abdelkader Posted June 28, 2021 Share Posted June 28, 2021 Si vous plait Commentaire rediriger au page précédente aprés connecté au compte !? Link to comment Share on other sites More sharing options...
Murat Kezli Posted June 28, 2021 Share Posted June 28, 2021 (edited) Simple; First find 'my_account_url' => $link->getPageLink('my-account', true), in ---> "/modules/ps_customersignin/ps_customersignin.php" file and change 'my-account' to "authentication" Turkish => Basit; İlk olarak aşağıdaki satırı 'my_account_url' => $link->getPageLink('my-account', true), bu dosya içinden ---> "/modules/ps_customersignin/ps_customersignin.php" bulun ve 'my-account' ı bununla değiştirin > "authentication" Edited June 28, 2021 by Murat Kezli (see edit history) Link to comment Share on other sites More sharing options...
Marwa Abdelkader Posted June 29, 2021 Share Posted June 29, 2021 @Murat Kezli thank you for your reply but it does not work my version of prestashop is 1.7.5 and I want when it connects to their account Redirect to last page after login Link to comment Share on other sites More sharing options...
Murat Kezli Posted June 29, 2021 Share Posted June 29, 2021 English => Have you cleared your cache? You can delete "prod" and "dev" folders in "/var/cache" ------ Turkish => Ön belleğinizi temizlediniz mi? "prod" ve "dev" klasörlerini "var/cache" içinden silebilirsiniz. Link to comment Share on other sites More sharing options...
Marwa Abdelkader Posted June 29, 2021 Share Posted June 29, 2021 @Murat Kezli Yes i clear cache and but it does not work ! Link to comment Share on other sites More sharing options...
Murat Kezli Posted June 29, 2021 Share Posted June 29, 2021 English => Ok, well you can "Disable non PrestaShop modules" in Performance and try agin please Turkish => Tamam, o zaman PrestaShop'a ait olmayan modülleri Menu / Advanced / Performance içinden devre dışı bırak tekrar deneyebilir misin? Link to comment Share on other sites More sharing options...
Marwa Abdelkader Posted June 30, 2021 Share Posted June 30, 2021 @Murat Kezli Hello Hello no does not work always when I connect it brings me back to the "my-account" page This is code of /ps_customersignin.php " <?php /** * Copyright since 2007 PrestaShop SA and Contributors * PrestaShop is an International Registered Trademark & Property of PrestaShop SA * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License 3.0 (AFL-3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: * https://opensource.org/licenses/AFL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to https://devdocs.prestashop.com/ for more information. * * @author PrestaShop SA and Contributors <[email protected]> * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ use PrestaShop\PrestaShop\Core\Module\WidgetInterface; if (!defined('_PS_VERSION_')) { exit; } class Ps_CustomerSignIn extends Module implements WidgetInterface { private $templateFile; public function __construct() { $this->name = 'ps_customersignin'; $this->author = 'PrestaShop'; $this->version = '2.0.3'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->getTranslator()->trans('Customer "Sign in" link', [], 'Modules.Customersignin.Admin'); $this->description = $this->getTranslator()->trans('Adds a block that displays information about the customer.', [], 'Modules.Customersignin.Admin'); $this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_]; $this->templateFile = 'module:ps_customersignin/ps_customersignin.tpl'; } public function getWidgetVariables($hookName, array $configuration) { $logged = $this->context->customer->isLogged(); if ($logged) { $customerName = $this->getTranslator()->trans( '%firstname% %lastname%', [ '%firstname%' => $this->context->customer->firstname, '%lastname%' => $this->context->customer->lastname, ], 'Modules.Customersignin.Admin' ); } else { $customerName = ''; } $link = $this->context->link; return [ 'logged' => $logged, 'customerName' => $customerName, /* * @deprecated */ 'logout_url' => $link->getPageLink('index', true, null, 'mylogout'), /* * @deprecated */ 'my_account_url' => $link->getPageLink('authentication', true), ]; } public function renderWidget($hookName, array $configuration) { $this->smarty->assign($this->getWidgetVariables($hookName, $configuration)); return $this->fetch($this->templateFile); } } " Link to comment Share on other sites More sharing options...
w3bsolutions Posted June 30, 2021 Share Posted June 30, 2021 There is nothing in ps_customersignin module that you can change to redirect the user to the previous page after login. It is not easy to do that because once the user logged in, the previous page is the login form, so what you would need is the page before... You need several changes in the code for that. It's not a 1 line change. 1 Link to comment Share on other sites More sharing options...
Marwa Abdelkader Posted June 30, 2021 Share Posted June 30, 2021 @w3bsolutions thank you for your answer Me I modify the redirection of page my account in page index in the file "customer login form" I add a line "Tools :: redirect ('index.ph'); it works do you have any idea how to redirect to the previous page Link to comment Share on other sites More sharing options...
Marwa Abdelkader Posted June 30, 2021 Share Posted June 30, 2021 Hello, problem solving In prestashop 1.7.5 on access / themes / templates / customer / _partials / login-form addition in the button sign in "<input type =" hidden "class =" hidden "name =" back "value =" {$ smarty.server.HTTP_REFERER} "/> {ls = 'Login' d = 'Shop.Theme .Actions'} " Link to comment Share on other sites More sharing options...
craneparts Posted October 29, 2021 Share Posted October 29, 2021 @w3bsolutions boa .. thanks a million for the module! .. It's a shame that there is no donate button here .. it would be worth donating for it 1 Link to comment Share on other sites More sharing options...
seyi Posted December 5, 2021 Share Posted December 5, 2021 (edited) On 6/30/2021 at 12:09 PM, Marwa Abdelkader said: Hello, problem solving In prestashop 1.7.5 on access / themes / templates / customer / _partials / login-form addition in the button sign in "<input type =" hidden "class =" hidden "name =" back "value =" {$ smarty.server.HTTP_REFERER} "/> {ls = 'Login' d = 'Shop.Theme .Actions'} " Best solution by far. Just for others, the code a little cleaned up, so you do not get a smarty parsing error: Redirect to previous page <input type="hidden" class="hidden" name="back" value="{$smarty.server.HTTP_REFERER}" /> Redirect to home page <input type="hidden" class="hidden" name="back" value="/" /> Edited December 5, 2021 by seyi (see edit history) Link to comment Share on other sites More sharing options...
Kami Solutions Posted July 29, 2022 Share Posted July 29, 2022 On 5/27/2021 at 11:37 PM, w3bsolutions said: As promised, attached is a simple module I did to redirect the customer to any page after logging in. Just put the URL you want to redirect to in the module settings: It can be relative, as in your case for the homepage: index.php Or it can be absolute, any URL such as : https://www.google.com You can undo your change to the core class and it will still work w3b_redirectonlogin.zip 7.95 kB · 81 downloads Thank you for the module, very elegant way to solve things in PrestaShop. Sad to see that a simply redirection of 1 line of code in the core would need so many lines in order to fix it😂 Works like a charm for PS 1.7.8.7 Link to comment Share on other sites More sharing options...
Fabricioc Posted May 23, 2023 Share Posted May 23, 2023 On 12/4/2021 at 9:14 PM, seyi said: Best solution by far. Just for others, the code a little cleaned up, so you do not get a smarty parsing error: Redirect to previous page <input type="hidden" class="hidden" name="back" value="{$smarty.server.HTTP_REFERER}" /> Redirect to home page <input type="hidden" class="hidden" name="back" value="/" /> It worked as it would. thanks for that. Link to comment Share on other sites More sharing options...
walala Posted June 15, 2023 Share Posted June 15, 2023 On 5/27/2021 at 11:37 PM, w3bsolutions said: As promised, attached is a simple module I did to redirect the customer to any page after logging in. Just put the URL you want to redirect to in the module settings: It can be relative, as in your case for the homepage: index.php Or it can be absolute, any URL such as : https://www.google.com You can undo your change to the core class and it will still work w3b_redirectonlogin.zip 7.95 kB · 138 downloads This module would be improved. In login checkckout redirect must be for checkout again. There are any way to differentiate 2 login forms? (in authentication & checkout). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now