Vitor Brito Posted September 3, 2013 Share Posted September 3, 2013 (edited) Hi everyone, I´ve searched the forum and posted in a few topics, but I didn´t had solved this problem:I want to redirect, after registration, the user to a cms page I´ve made.I´ve changed AuthController, and pasted after " // if register process is in two steps, we display a message to confirm account creation", but it only works with external links:Tools::redirect('http://www.google.com');does not work with content from my domain:Tools::redirect('cms.php?id_cms=5'); Tools::redirect('registsucess.php'); Tools::redirect('http://MYDOMAIN.COM'); I´ve tried with tinyurl as well, but didn´t work too. Can someone tell me what´s wrong?Thanks in advance!! Edited September 4, 2013 by Vitor Brito (see edit history) Link to comment Share on other sites More sharing options...
Vitor Brito Posted September 9, 2013 Author Share Posted September 9, 2013 Anybody? Link to comment Share on other sites More sharing options...
Beluga Posted September 30, 2013 Share Posted September 30, 2013 (edited) I succeeded with this: $linktoAboutUs = $this->context->link->getCMSLink(4); Tools::redirect($linktoAboutUs); It's kind of weird that according to this advice we could use the friendly name of the CMS page, but I couldn't get it to work. Tried getCMSLink('about-us') and even getCMSLink('About us'). And in the link.php class function the $cms parameter is described "can be an ID, but deprecated". This would indicate that we actually SHOULD NOT use an ID.. but how, when it is ALL that works?? /** * Create a link to a CMS page * * @param mixed $cms CMS object (can be an ID CMS, but deprecated) * @param string $alias * @param bool $ssl * @param int $id_lang * @return string */ public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null) Edited September 30, 2013 by Beluga (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted September 30, 2013 Share Posted September 30, 2013 you should use something like: $cms = new CMS(2); $link->getCmsLink($cms); Link to comment Share on other sites More sharing options...
submegamanx Posted April 6, 2014 Share Posted April 6, 2014 you should use something like: $cms = new CMS(2); $link->getCmsLink($cms); I have tired to insert rediretct after regitration user with this: header("location: http://www.linksite.com/content/9-registration-success"); exit(0); but the sytem redirect every on page login and ignore my link.... BECAUSEEEE Link to comment Share on other sites More sharing options...
vekia Posted April 7, 2014 Share Posted April 7, 2014 where you pasted this code? everything depends on it i just thing that your code is not executed Link to comment Share on other sites More sharing options...
submegamanx Posted April 7, 2014 Share Posted April 7, 2014 where you pasted this code? everything depends on it i just thing that your code is not executed If I comment header("location: http://www.linksite....tration-success"); the script stop on exit, and I view a wite page. If I not comment the redirect line, the script continue and redirec to access page, I would redirect to specific CMS page Have solutions? Link to comment Share on other sites More sharing options...
vincent89 Posted July 10, 2014 Share Posted July 10, 2014 prestashop 1.6.0.8 I Found the solution without modify anything in the presta files. enable ssl and force the ssl on all pages but uncheck html purifier library (very important). you could enable it after insert the image. then go on CMS (exemple: about us) the image who's already there when you install prestashop work well even in ssl so you have to copy how they wrote the code. <img title="cms-img" src="../img/cms/cms-img.jpg" alt="cms-img" width="370" height="192" /> replace by your name image <img title="your name image" src="../img/cms/your name image.jpg" alt="your name image" width="370" height="192" /> write this way on the little popup window [insert/edit image] right after uploaded and chose the image from your file manager. source ../img/cms/your name image.jpg image description .... dimensions ... Save it and go to enable the html filter purifier if you done to put new images. Now it should work. your image is here and your page is still SSL. ps: you'll have to disable html purifier library every time you need to add a new picture from your file manager otherwise it will appear this famous question mark instead of the image and your page won't be SSL It tooks 2weeks to found that, I hope you'll appreciate this post. That's the most annoying bug on prestashop, I don't even know why the Presta team didn't fix that so far!!!!???? I still have a problem with the homeslider who's disappear when running on Safari, need to refresh the page every time I come back on the home page!!! if somebody have the Solution I'll appreciate to know it thanks vince Link to comment Share on other sites More sharing options...
HouseofJewellery Posted June 29, 2018 Share Posted June 29, 2018 On 7/10/2014 at 6:03 AM, vincent89 said: prestashop 1.6.0.8 I Found the solution without modify anything in the presta files. enable ssl and force the ssl on all pages but uncheck html purifier library (very important). you could enable it after insert the image. then go on CMS (exemple: about us) the image who's already there when you install prestashop work well even in ssl so you have to copy how they wrote the code. <img title="cms-img" src="../img/cms/cms-img.jpg" alt="cms-img" width="370" height="192" /> replace by your name image <img title="your name image" src="../img/cms/your name image.jpg" alt="your name image" width="370" height="192" /> write this way on the little popup window [insert/edit image] right after uploaded and chose the image from your file manager. source ../img/cms/your name image.jpg image description .... dimensions ... Save it and go to enable the html filter purifier if you done to put new images. Now it should work. your image is here and your page is still SSL. ps: you'll have to disable html purifier library every time you need to add a new picture from your file manager otherwise it will appear this famous question mark instead of the image and your page won't be SSL It tooks 2weeks to found that, I hope you'll appreciate this post. That's the most annoying bug on prestashop, I don't even know why the Presta team didn't fix that so far!!!!???? I still have a problem with the homeslider who's disappear when running on Safari, need to refresh the page every time I come back on the home page!!! if somebody have the Solution I'll appreciate to know it thanks vince This didnt solve my problem at all.. Link to comment Share on other sites More sharing options...
rmiho Posted January 12, 2019 Share Posted January 12, 2019 does anyone have the solution? I am looking a way to redirect to different page as soon as customer click on save button in registration form. thanks Link to comment Share on other sites More sharing options...
rmiho Posted January 13, 2019 Share Posted January 13, 2019 (edited) figured it out how to redirect to address page after new user register Edited January 13, 2019 by rmiho (see edit history) Link to comment Share on other sites More sharing options...
lucascaibe Posted January 24, 2019 Share Posted January 24, 2019 On 1/13/2019 at 9:57 AM, rmiho said: figured it out how to redirect to address page after new user register can you tell me the solution? I have the same problem. Link to comment Share on other sites More sharing options...
rmiho Posted January 24, 2019 Share Posted January 24, 2019 2 hours ago, lucascaibe said: can you tell me the solution? I have the same problem. edit the file /controllers/front/AuthController.php (backup the file before you modify anything) find below $should_redirect = false; add after above $ggw_should_redirect = false; find below if ($hookResult && $register_form->submit()) { $should1_redirect = true; and replace above with if ($hookResult && $register_form->submit()) { $ggw_should_redirect = true; find if clause if ($should_redirect && !$this->ajax) { and after end if clause add below if clause if ($ggw_should_redirect && !$this->ajax) { $back = urldecode(Tools::getValue('back')); if (Tools::urlBelongsToShop($back)) { return $this->redirectWithNotifications('address'); } if ($this->authRedirection) { return $this->redirectWithNotifications($this->authRedirection); } // go home return $this->redirectWithNotifications(__PS_BASE_URI__); } Link to comment Share on other sites More sharing options...
Psarco Posted January 25, 2019 Share Posted January 25, 2019 Quote Hello rmiho, thanks for your help, I try to implement your solution but nothing happen, prestashop still send me to home page after registration, can you ple take a look on my file in order to check if a implement the modifications correctly? * International Registered Trademark & Property of PrestaShop SA */ class AuthControllerCore extends FrontController { public $ssl = true; public $php_self = 'authentication'; public $auth = false; public function checkAccess() { if ($this->context->customer->isLogged() && !$this->ajax) { $this->redirect_after = ($this->authRedirection) ? urlencode($this->authRedirection) : 'my-account'; $this->redirect(); } return parent::checkAccess(); } public function initContent() { $should_redirect = false; $ggw_should_redirect = false; if (Tools::isSubmit('submitCreate') || Tools::isSubmit('create_account')) { $register_form = $this ->makeCustomerForm() ->setGuestAllowed(false) ->fillWith(Tools::getAllValues()) ; if (Tools::isSubmit('submitCreate')) { $hookResult = array_reduce( Hook::exec('actionSubmitAccountBefore', array(), null, true), function ($carry, $item) { return $carry && $item; }, true ); if ($hookResult && $register_form->submit()) { $ggw_should_redirect = true; } } $this->context->smarty->assign([ 'register_form' => $register_form->getProxy(), 'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop') ]); $this->setTemplate('customer/registration'); } else { $login_form = $this->makeLoginForm()->fillWith( Tools::getAllValues() ); if (Tools::isSubmit('submitLogin')) { if ($login_form->submit()) { $should_redirect = true; } } $this->context->smarty->assign([ 'login_form' => $login_form->getProxy() ]); $this->setTemplate('customer/authentication'); } parent::initContent(); if ($should_redirect && !$this->ajax) { $back = urldecode(Tools::getValue('back')); if (Tools::urlBelongsToShop($back)) { // Checks to see if "back" is a fully qualified // URL that is on OUR domain, with the right protocol return $this->redirectWithNotifications($back); } // Well we're not redirecting to a URL, // so... if ($this->authRedirection) { // We may need to go there if defined return $this->redirectWithNotifications($this->authRedirection); } // go home return $this->redirectWithNotifications(__PS_BASE_URI__); } if ($ggw_should_redirect && !$this->ajax) { $back = urldecode(Tools::getValue('back')); if (Tools::urlBelongsToShop($back)) { return $this->redirectWithNotifications('address'); } if ($this->authRedirection) { return $this->redirectWithNotifications($this->authRedirection); } // go home return $this->redirectWithNotifications(__PS_BASE_URI__); } } } Thanks in advance, have a nice day Link to comment Share on other sites More sharing options...
rmiho Posted January 25, 2019 Share Posted January 25, 2019 11 minutes ago, Psarco said: Hello rmiho, thanks for your help, I try to implement your solution but nothing happen, prestashop still send me to home page after registration, can you ple take a look on my file in order to check if a implement the modifications correctly? * International Registered Trademark & Property of PrestaShop SA */ class AuthControllerCore extends FrontController { public $ssl = true; public $php_self = 'authentication'; public $auth = false; public function checkAccess() { if ($this->context->customer->isLogged() && !$this->ajax) { $this->redirect_after = ($this->authRedirection) ? urlencode($this->authRedirection) : 'my-account'; $this->redirect(); } return parent::checkAccess(); } public function initContent() { $should_redirect = false; $ggw_should_redirect = false; if (Tools::isSubmit('submitCreate') || Tools::isSubmit('create_account')) { $register_form = $this ->makeCustomerForm() ->setGuestAllowed(false) ->fillWith(Tools::getAllValues()) ; if (Tools::isSubmit('submitCreate')) { $hookResult = array_reduce( Hook::exec('actionSubmitAccountBefore', array(), null, true), function ($carry, $item) { return $carry && $item; }, true ); if ($hookResult && $register_form->submit()) { $ggw_should_redirect = true; } } $this->context->smarty->assign([ 'register_form' => $register_form->getProxy(), 'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop') ]); $this->setTemplate('customer/registration'); } else { $login_form = $this->makeLoginForm()->fillWith( Tools::getAllValues() ); if (Tools::isSubmit('submitLogin')) { if ($login_form->submit()) { $should_redirect = true; } } $this->context->smarty->assign([ 'login_form' => $login_form->getProxy() ]); $this->setTemplate('customer/authentication'); } parent::initContent(); if ($should_redirect && !$this->ajax) { $back = urldecode(Tools::getValue('back')); if (Tools::urlBelongsToShop($back)) { // Checks to see if "back" is a fully qualified // URL that is on OUR domain, with the right protocol return $this->redirectWithNotifications($back); } // Well we're not redirecting to a URL, // so... if ($this->authRedirection) { // We may need to go there if defined return $this->redirectWithNotifications($this->authRedirection); } // go home return $this->redirectWithNotifications(__PS_BASE_URI__); } if ($ggw_should_redirect && !$this->ajax) { $back = urldecode(Tools::getValue('back')); if (Tools::urlBelongsToShop($back)) { return $this->redirectWithNotifications('address'); } if ($this->authRedirection) { return $this->redirectWithNotifications($this->authRedirection); } // go home return $this->redirectWithNotifications(__PS_BASE_URI__); } } } Thanks in advance, have a nice day What version of prestashop you running? I see your contents identical to mine. Do you have a dev/demo site? Did you clear the cache? Link to comment Share on other sites More sharing options...
Psarco Posted January 25, 2019 Share Posted January 25, 2019 Thanks for the support I'm runing 1.7.4 No, because I don't have able the cache. and I just have the site where i'm working right now Link to comment Share on other sites More sharing options...
rmiho Posted February 24, 2019 Share Posted February 24, 2019 i was using 1.7.5 and just upgraded to 1.7.5.1 but the changes i did were gone. So i added the code again and working as expected Link to comment Share on other sites More sharing options...
kreatywneprojektowan Posted October 27, 2019 Share Posted October 27, 2019 Not working for me. 1.7.4.4 Link to comment Share on other sites More sharing options...
rmiho Posted October 28, 2019 Share Posted October 28, 2019 Hi, could you please share the content of the file post edit so can look into it. may be upgrade the store to latest version? 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 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 Link to comment Share on other sites More sharing options...
Alex Weiss Posted April 28, 2020 Share Posted April 28, 2020 On 1/25/2019 at 5:40 AM, Psarco said: Hello rmiho, thanks for your help, I try to implement your solution but nothing happen, prestashop still send me to home page after registration, can you ple take a look on my file in order to check if a implement the modifications correctly? * International Registered Trademark & Property of PrestaShop SA */ class AuthControllerCore extends FrontController { public $ssl = true; public $php_self = 'authentication'; public $auth = false; public function checkAccess() { if ($this->context->customer->isLogged() && !$this->ajax) { $this->redirect_after = ($this->authRedirection) ? urlencode($this->authRedirection) : 'my-account'; $this->redirect(); } return parent::checkAccess(); } public function initContent() { $should_redirect = false; $ggw_should_redirect = false; if (Tools::isSubmit('submitCreate') || Tools::isSubmit('create_account')) { $register_form = $this ->makeCustomerForm() ->setGuestAllowed(false) ->fillWith(Tools::getAllValues()) ; if (Tools::isSubmit('submitCreate')) { $hookResult = array_reduce( Hook::exec('actionSubmitAccountBefore', array(), null, true), function ($carry, $item) { return $carry && $item; }, true ); if ($hookResult && $register_form->submit()) { $ggw_should_redirect = true; } } $this->context->smarty->assign([ 'register_form' => $register_form->getProxy(), 'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop') ]); $this->setTemplate('customer/registration'); } else { $login_form = $this->makeLoginForm()->fillWith( Tools::getAllValues() ); if (Tools::isSubmit('submitLogin')) { if ($login_form->submit()) { $should_redirect = true; } } $this->context->smarty->assign([ 'login_form' => $login_form->getProxy() ]); $this->setTemplate('customer/authentication'); } parent::initContent(); if ($should_redirect && !$this->ajax) { $back = urldecode(Tools::getValue('back')); if (Tools::urlBelongsToShop($back)) { // Checks to see if "back" is a fully qualified // URL that is on OUR domain, with the right protocol return $this->redirectWithNotifications($back); } // Well we're not redirecting to a URL, // so... if ($this->authRedirection) { // We may need to go there if defined return $this->redirectWithNotifications($this->authRedirection); } // go home return $this->redirectWithNotifications(__PS_BASE_URI__); } if ($ggw_should_redirect && !$this->ajax) { $back = urldecode(Tools::getValue('back')); if (Tools::urlBelongsToShop($back)) { return $this->redirectWithNotifications('address'); } if ($this->authRedirection) { return $this->redirectWithNotifications($this->authRedirection); } // go home return $this->redirectWithNotifications(__PS_BASE_URI__); } } } Thanks in advance, have a nice day helloo! yes yes yes! for me it worked perfectly, adding exactly this way! thanks to all of you and I hope this works for others as well as it helped me! thanks! Att alex weiss 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