lemoeb Posted September 22, 2019 Share Posted September 22, 2019 (edited) I need to change the redirect after a customer has registered. In the form I am writing, I intercept the ActionCustomerAccountAdd Hook correctly and perform the operations necessary to my form. Without this, however, I would like to see my .tpl file and not the default prestashop file. I tried using Tools :: redirect but got nothing. Tips on how to do it? Thanks in advance My Code : Quote public function hookActionCustomerAccountAdd($param) { Tools::redirect('views/templates/front/confirm.tpl'); } P.S. After registering (since I disable the automatic client activation) I return to the registration screen itself (as in the figure), I would like to avoid this and make a riderect to a specific message of mine. Edited September 22, 2019 by lemoeb (see edit history) Link to comment Share on other sites More sharing options...
NFORLA Posted April 27, 2020 Share Posted April 27, 2020 Hi @lemoeb, did you manage to solve this? I'm in similar situation... Link to comment Share on other sites More sharing options...
Verlonimo Posted April 27, 2020 Share Posted April 27, 2020 Hi, Prestashop has back param so inside your form try to add: <input type="hidden" name="back" value="path_to_your_controller"> So after submitting form it will redirect you to your page. Hoe that helps. Thanks 1 Link to comment Share on other sites More sharing options...
NFORLA Posted April 28, 2020 Share Posted April 28, 2020 17 hours ago, Verlonimo said: Hi, Prestashop has back param so inside your form try to add: <input type="hidden" name="back" value="path_to_your_controller"> So after submitting form it will redirect you to your page. Hoe that helps. Thanks Hi @Verlonimo, first of all, thanks for your response. I wasn't able to solve the problem with your solution. In my case im doing this inside my hookActionCustomerAccountAdd: $registrationRedirectUrl = $this->context->link->getModuleLink($this->name, 'Registration'); Tools::redirect($registrationRedirectUrl); But for some reason(im working on localhost) it goes straight to 127.0.0.1(prestashop is at localhost/prestashop) after registration. Same with logout. I'm starting to think it is something related to Apache configurations. Can anyone give a hint? Link to comment Share on other sites More sharing options...
Verlonimo Posted April 28, 2020 Share Posted April 28, 2020 Hi, @NFORLA Well, as example: In login-form.tpl if you would add this : <input type="hidden" name="back" value="{$urls.pages.history}"> It will redirect you to order history page after login. I just tested it on my end and it works. So i assume if you would do same in your form it should work. Unless i don't understand what you want to do? Thanks Link to comment Share on other sites More sharing options...
binshops Posted April 17, 2021 Share Posted April 17, 2021 Hi, if you want to intercept the customer registration, you need to actually do a logout. Why? because PrestaShop checks if you are a banned user or not, and you will be redirected to the previous page (which is registration page). This happens when PrestaShop initializes your controller in "FrontController.php". Here: if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id))) { $this->context->customer->logout(); Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null); } so, to fix this (and to prevent redirect to previous page), you can do this in your hook before redirect: global $cookie; $id_lang = $cookie->id_lang; $cookie->logout(); $cookie->id_lang = $id_lang; $cookie->write(); 1 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