Right, I already have advanced permissions enabled... I tried marking the "You need to login to view this content" block visible to only guests, and the actual login-required content visible to everyone except guests. However, the guest-only content is still viewable after login. Understand my question? Thank you.
Currently, Concrete5 Treats all users as guests, no matter what group they are in, you can use an isLoggedin(); check in php in a custom block to add that functionality
I installed the PHP block add-on. I am trying to add this functionality by putting the following code into a php block. I am new to php, and it is returning errors. Can you help?
Basically, if a visitor hits the current page and they are not logged in, they will still see the current page they are on. If a visitor hits the page and is logged in, I want it to redirect over to a new page.
I just ran into this same thing, and here's the most straightforward fix, IMO. Create a custom template. For instance, create a "guest_only.php" file in blocks/content/templates with this:
<?phpdefined('C5_EXECUTE') or die("Access Denied.");$content=$controller->getContent();$page= Page::getCurrentPage();$u=new User();if(!$u->isRegistered()||$page->isEditMode())){echo$content;}?>
Similarly, you could use the condition above on a more complex block type and just include the original template where you see echo $content above.
Code
Post Reply
Delete Post
You are allowed to delete your post for 5 minutes after it's posted.