EQ10000 Posted January 6, 2012 Share Posted January 6, 2012 We want to set the new registered customer to inactive, and we will set it active by manual or other way. In AuthController.php, there is a "$customer->active = 1;" to use. If we change it to "$customer->active = 0;", that will make the new registered customer to inactive and not logined. However, the Tool::redirect('newuser.php') cannot work as expected. It would not redirect, the browser will show authentication.php after registered and not redirect. Firstly, lets go to classes/tools.php, the function redirect will use $_SERVER['HTTP_REFERER'] in the Tools::redirect function and not the second part to use url. Furthermore, even if we call Tool::redirectLink(newuser.php) instead Tool::redirect(newuser.php), or directly use header('Location: http//foobar.com/newuser.php'), the result is same, the browser still stay in the page of authentication.php Any idea to make the new registered customer inactive and the redirect may get function. 1 Link to comment Share on other sites More sharing options...
EQ10000 Posted January 27, 2012 Author Share Posted January 27, 2012 After our code redirect(newuser.php); The newuser.php will call Controller which from FrontController. There is another call in FrontController.php near line 120 if (isset($_GET['logout']) OR ($cookie->logged AND Customer::isBanned((int)$cookie->id_customer))) As the user is not allow to login... Another redirect to $_SERVER['HTTP_REFERER'], that is authentication.php How to fix... In AuthController.php change active to 0 $customer->active = 0; // change to not active a few lines below, change logged to 0 self::$cookie->logged =0; // change to not logged 2 Link to comment Share on other sites More sharing options...
sadlyblue Posted November 15, 2012 Share Posted November 15, 2012 Hi, It worked in prestashop 1.5.2 Just need the correct $customer->active = 0; to change since there are more than one. When i changed the 2nd one, the cookie, i created a new account, it defaulted to disabled and i couldn't log in with it... Thanks for taking the time to post the solution after you found it. Link to comment Share on other sites More sharing options...
erfinestra1977 Posted April 12, 2013 Share Posted April 12, 2013 Sorry, but I have the problem that when you enable the user does not get an email confirmation, how can you solve? many thanks Link to comment Share on other sites More sharing options...
pawel445 Posted April 14, 2013 Share Posted April 14, 2013 I've the same problem with redirection when customer is set to inactive. Anyone can help? Link to comment Share on other sites More sharing options...
lain Posted May 5, 2013 Share Posted May 5, 2013 In PS 1.4.5.1 I solved this problem changing line 205~ in controllers/AuthController.php Tools::redirect('my-account.php'); changing it to Tools::redirect('cms.php?id_cms=14'); or friendly url Tools::redirect('content/custompage'); Link to comment Share on other sites More sharing options...
1337 Posted June 4, 2013 Share Posted June 4, 2013 solved the redirect problem at newest ps with Tools::redirect('http://YOURURL'); pasted in line 675 (after comment // if register process is in two steps, we display a message to confirm account creation) THANKS 1 Link to comment Share on other sites More sharing options...
Vitor Brito Posted August 29, 2013 Share Posted August 29, 2013 I did what 1337 posted, but it only works with external links (i.e. Tools::redirect('http://www.google.com');, but not with content from my domain ( i.e Tools::redirect('cms.php?id_cms=5'); Can someone tell me what´s wrong? Link to comment Share on other sites More sharing options...
woodxxman Posted August 30, 2014 Share Posted August 30, 2014 I change the code in FrontController.php of ps1.6 if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id))) { $this->context->customer->logout(); Tools::redirect('index.php?controller=cms&id_cms=6'); } so it will redirect to the page with message "the customer is still not activated by the admin" 1 Link to comment Share on other sites More sharing options...
El Patron Posted August 30, 2014 Share Posted August 30, 2014 redirect after inactivating a registration requires that one logout the customer before redirect, for example (before redirect) if (substr(_PS_VERSION_, 0, 3) == '1.4') { global $cookie; $cookie->logout(); }else{ $this->context->customer->logout(); } followed by other logic and then redirect Link to comment Share on other sites More sharing options...
woodxxman Posted August 30, 2014 Share Posted August 30, 2014 redirect after inactivating a registration requires that one logout the customer before redirect, for example (before redirect) if (substr(_PS_VERSION_, 0, 3) == '1.4') { global $cookie; $cookie->logout(); }else{ $this->context->customer->logout(); } followed by other logic and then redirect but the inactivated customer still get no message when he try to login right? Link to comment Share on other sites More sharing options...
El Patron Posted August 30, 2014 Share Posted August 30, 2014 but the inactivated customer still get no message when he try to login right? the redirect should tell them that their account request has been received, that they will be emailed when account has been approved....etc etc...yes? Link to comment Share on other sites More sharing options...
woodxxman Posted August 30, 2014 Share Posted August 30, 2014 the redirect should tell them that their account request has been received, that they will be emailed when account has been approved....etc etc...yes? yes, give them the infomation is it the right place to change the code in frontController? if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id))) { $this->context->customer->logout(); Tools::redirect('index.php?controller=cms&id_cms=6'); } cms 6 is where i edit the message for these customers Link to comment Share on other sites More sharing options...
El Patron Posted August 30, 2014 Share Posted August 30, 2014 yes, give them the infomation is it the right place to change the code in frontController? if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id))) { $this->context->customer->logout(); Tools::redirect('index.php?controller=cms&id_cms=6'); } cms 6 is where i edit the message for these customers I can't help with core hacks (not recommended), this sort of code should be hooked in module, ActionCustomerAccountAdd if you hack core, you will lose when upgrade. You can get an idea of how a module handles this situation here. Link to comment Share on other sites More sharing options...
Famke Posted July 2, 2020 Share Posted July 2, 2020 Does anyone know how to fix this in version 1.7? 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