Jump to content

Set new registered customer inactive, redirect failed


EQ10000
 Share

Recommended Posts

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.

  • Like 1

Share this post


Link to post
Share on other sites

  • 3 weeks later...

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

  • Like 2

Share this post


Link to post
Share on other sites

  • 9 months later...

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.

Share this post


Link to post
Share on other sites

  • 4 months later...
  • 3 weeks later...

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

Share this post


Link to post
Share on other sites

  • 5 weeks later...

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

  • Like 1

Share this post


Link to post
Share on other sites

  • 2 months later...

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?

Share this post


Link to post
Share on other sites

  • 1 year later...
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"
  • Like 1

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

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.

Share this post


Link to post
Share on other sites

  • 5 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
 Share

×
×
  • Create New...

Important Information

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