Jump to content

[PS 1.7.6] How to change redirect after Customer registration


Recommended Posts

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.

 

Schermata del 2019-09-22 18-32-40.png

Edited by lemoeb (see edit history)
Link to comment
Share on other sites

  • razaro changed the title to [PS 1.7.6] How to change redirect after Customer registration
  • 7 months later...
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

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

  • 11 months later...

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();

 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...