Jump to content

CMS only for Logged users


wilebaldo

Recommended Posts

Hello I need to make some CMS page private for only Logged customers, I found this:
https://www.prestashop.com/forums/topic/335647-how-to-make-a-cms-page-only-for-logged-in-customers/

 

And I modify my CMSController.PHP and is working, but this is for ALL the CMS page, and I need ONLY for 1 page, is any another way to do? or I can make two kind of CMS pages, some private and other ones public?

 

Thanks!

Link to comment
Share on other sites

You can make the change but add the id of the cms you want to filter i havent test it but something like these

 

    public function initContent()
    {

		$id_cms = (int) Tools::getValue('id_cms');

		if ( ($id_cms === code of cms you want hide) && (!$this->context->customer->isLogged()) ){
	
			Tools::redirect('index.php?controller=authentication');
		}
        parent::initContent();
    }

 

you can in fact add a field to the database then read if is private and use that value

I think the call should be back value to return to the page after the login

 

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