Jump to content

[SOLVED] Log out url redirect


Recommended Posts

Hi! I have one problem:

 

When customer log on front end and go to product categories and then click log out customers is redirected to index page. I need to log out button redirected directly to login (authorization) page. My default index page also redirects to log in page. Prestashop 1.5.4.1 with modified default theme. Thanks! :mellow:

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

SOLVED!

 

I change FrontController.php lines

 

[color=#245D98][font=Courier, Tahoma, serif, Simsun][size=3]if (isset($_GET['logout']) OR ($cookie->logged AND Customer::isBanned((int)$cookie->id_customer)))[/size][/font][/color]
[color=#245D98][font=Courier, Tahoma, serif, Simsun][size=3]		{[/size][/font][/color]
[color=#245D98][font=Courier, Tahoma, serif, Simsun][size=3]			$cookie->logout();[/size][/font][/color]
[color=#245D98][font=Courier, Tahoma, serif, Simsun][size=3]			Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);[/size][/font][/color]
[color=#245D98][font=Courier, Tahoma, serif, Simsun][size=3]		}[/size][/font][/color]
[color=#245D98][font=Courier, Tahoma, serif, Simsun][size=3]		elseif (isset($_GET['mylogout']))[/size][/font][/color]
[color=#245D98][font=Courier, Tahoma, serif, Simsun][size=3]		{[/size][/font][/color]
[color=#245D98][font=Courier, Tahoma, serif, Simsun][size=3]			$cookie->mylogout();[/size][/font][/color]
[color=#245D98][font=Courier, Tahoma, serif, Simsun][size=3]			Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);[/size][/font][/color]
[color=#245D98][font=Courier, Tahoma, serif, Simsun][size=3]		}[/size][/font][/color]

 

TO

 

if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id)))
{
$this->context->customer->logout();

Tools::redirect('index.php?controller=authentication?back=my-account');
}
elseif (isset($_GET['mylogout']))
{
$this->context->customer->mylogout();
Tools::redirect('index.php?controller=authentication?back=my-account');

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...
  • 5 weeks later...
  • 2 months later...
  • 7 months later...
  • 1 month later...

I think override is best. ;)

override > classes > controller > FrontController.php

<?php

class FrontController extends FrontControllerCore
{

  public function init()
  { 
    if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id)))
    {
      $_SERVER['HTTP_REFERER'] = _PS_BASE_URL_;
    }
    elseif (isset($_GET['mylogout']))
    {
      $_SERVER['HTTP_REFERER'] = _PS_BASE_URL_;
    }
    parent::init();
  }

}
Edited by YanK (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 6 years later...

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