Jump to content
dellwen!!@@

redirect after login - Prestashop 1.7

Recommended Posts

Hello use 1.7.1.2

I solved this. I spend many time searching but nothing after all I found a answer :lol:

  1. 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),

     

  2. 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.

  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites

after spending few days managed to redirect to address page as soon as new user register.

 

Share this post


Link to post
Share on other sites

In controllers/front/AuthController.php  add this line :

$url = 'your-page-link'; // example 'my-account'
$back = $back ? $back : $url;

After 

$back = urldecode(Tools::getValue('back'));

 

    if ($should_redirect && !$this->ajax) {
            $back = urldecode(Tools::getValue('back'));
            $back = $back ? $back : 'my-account';
            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__);
        }

 

Edited by idrissElbasrii (see edit history)
  • Thanks 1

Share this post


Link to post
Share on other sites

check out below thread

https://www.prestashop.com/forums/topic/272089-redirect-to-internal-link/?tab=comments#comment-3049983

 

Share this post


Link to post
Share on other sites
Posted (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 :lol:

  1. 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),

     

  2. 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 by Maryando
Mistake (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

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

  • Like 2

Share this post


Link to post
Share on other sites
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/

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More