cinny2205 Posted January 7, 2015 Share Posted January 7, 2015 Hi, Could any one advise how to create CMS pages which is "only visible" when member logged in? I want to make some information for members only. Following is my site www.genfortune.com.hk Thanks! Cinny Link to comment Share on other sites More sharing options...
Rolige Posted January 7, 2015 Share Posted January 7, 2015 With the native options is not possible, you need a module for this. Link to comment Share on other sites More sharing options...
fred-vinapresta Posted January 7, 2015 Share Posted January 7, 2015 Hi, you can override the init() function of your CmsController.php file by adding something like: if (!$this->context->customer->isLogged()) Tools::redirect('the page you want'); or send this logged state from cmsController to your template by smarty $this->smarty->assign(array( 'logged' => $this->context->customer->isLogged() )); and add a condition in your template cms.tpl {if $logged} display cms {else} display custom message {/if} if you that works for few cms page, add a condition on cms page id 1 Link to comment Share on other sites More sharing options...
elescano Posted February 1, 2015 Share Posted February 1, 2015 Hi! I have done how fred-vinepresta suggested in his posts. So all my cms pages now are accessible only for logged users. I would like that only one page has restriced access while all over the other ones are public. If, for example, my cms page which has to be accessible only for logged users has id=6, what do i have to do? Link to comment Share on other sites More sharing options...
fred-vinapresta Posted February 1, 2015 Share Posted February 1, 2015 Hi, in your template you can put {if !$logged AND $cms->id == 6} display custom message{else}display cms {/if} Link to comment Share on other sites More sharing options...
elescano Posted February 1, 2015 Share Posted February 1, 2015 Still it is working for all my cms pages Link to comment Share on other sites More sharing options...
joaomag Posted May 23, 2015 Share Posted May 23, 2015 Hi, Just need to change the 1st line o the CmsContoler to: if (!$this->context->customer->isLogged() AND $cms->id == 6) Hope it help you Link to comment Share on other sites More sharing options...
wilebaldo Posted December 5, 2018 Share Posted December 5, 2018 (edited) I have to do this also to my store with only one CMS page, and this was the solution for me. In prestashop 1.6 modify the file CmsController.php just above this line: parent::initContent(); I add this code if (!$this->context->customer->isLogged() && $this->cms->id == 6) { Tools::redirect('index.php?controller=authentication'); } the first line is a conditional to check if the customer is not logged and if the page CMS is they required is the one I need to protect for only customer registered in my case is the page 6. in cas the conditions is true, will be redirected to the login page. Comparing with the code made more above for other was not working because is missing the double "&&" and the "$this->cms->" and also the open and close { } for the if conditional, with this everything is working fine. Edited December 5, 2018 by wilebaldo (see edit history) Link to comment Share on other sites More sharing options...
PF22 Posted June 11, 2019 Share Posted June 11, 2019 (edited) On 12/6/2018 at 12:15 AM, wilebaldo said: I add this code if (!$this->context->customer->isLogged() && $this->cms->id == 6) { Tools::redirect('index.php?controller=authentication'); } Hi there! Is there a way for the customer to automatically go back to cms 6 page after authentification ? I tried somthing like that but it failed... Tools::redirect('index.php?controller=authentication?back=/content/29-my-page/') Edited June 11, 2019 by Pat_07 syntax error (see edit history) Link to comment Share on other sites More sharing options...
PF22 Posted June 12, 2019 Share Posted June 12, 2019 I also tried the syntax below, but once again after authentification it led me to home page {Tools::redirect('index.php?controller=authentication?back=$link->getCMSLink(9)')} 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