Jump to content

How To Redirect From Login Page To My Custom Cms Page?


revv83

Recommended Posts

Hello. I've following problem. I need to require login when user goes to one cms page. I just added in CmsController.php such code:

if (!$this->context->customer->isLogged() && $id_cms == 6) {

Tools::redirect('index.php?controller=authentication?back=index.php');
}
 
But how can I change ?back=index.php reference to my own link? I was trying to insert here path to cms page but it's not working. I want to redirect user back to this cms page after login.
 
Please help. Thanks in advance.
Link to comment
Share on other sites

Hello you can try the folowing code

if (!$this->context->customer->isLogged() && $id_cms == 6) {
 $cms = new Cms($id_cms , $this->context->language->id);
 $cmsLink = $this->context->link->getCMSLink($cms);
 Tools::redirect('index.php?controller=authentication?back='.$cmsLink);
}
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...