I want to have a public and private (logged in users) section on the front-end. Is that possible on craft?
Asked
Active
Viewed 1,577 times
1 Answers
8
Yes. You need to build a frontend login form and then block non logged in users from seeing the entries with something along the lines of this:
{% if craft.session.isLoggedIn %}
{# put content here #}
{% endif %}
You can also check if the user belongs to a specific group with isInGroup('groupHandle') (more here)
megatrond
- 1,342
- 6
- 15
{% if currentUser %}, which will returnfalseif the user is not logged in. – Lindsey D Aug 10 '15 at 17:56{% requireLogin %}will redirect you to yourloginPathif you are not logged in. More here – megatrond Aug 23 '15 at 07:10{% if currentUser %}should definitely still work: https://docs.craftcms.com/v3/dev/global-variables.html#currentuser There's also the page-wide{% requireLogin %}tag, but that probably doesn't prevent the entry from showing up on listing pages. – Sandwich Apr 13 '20 at 18:06