We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How to selectively display restricted content

How Do I?

rjionline's avatar
rjionline
37 posts
10 years ago
rjionline's avatar rjionline

So, I built an EE site. Per my instructions, there’s a section of content that is restricted to users who are logged into the site. All good so far,

Now, we’d like to selectively display some of that content to non-authenticated users. For example, we want to open up one of the posts for a few days, but keep the rest restricted.

Ideally, this needs to be something that doesn’t require changes to the template every time we want to display a post. The people opening up these posts don’t have the skills to do that.

I was thinking there might be a way to assign a new category or status that gets around the need to be logged in to view a post, but I haven’t thought through that idea yet.

Any suggestions?

Thanks.

Lamar

EE v2.9.0 - Build Date: 20140715

       
airways's avatar
airways
154 posts
10 years ago
airways's avatar airways

What method did you use to hide the content in the template? Seeing your template code would help. Assuming you used a conditional like

{exp:channel:entries ...}
{if logged_in_member_id}
{/if}
{/exp:channel:entries}

Then you can just add the new condition

{exp:channel:entries ...}
{if logged_in_member_id || "{categories}{category_url_title}|{/categories}" *= "free-entry"}
{/if}
{/exp:channel:entries}

You would then assign any entries that are to be made available to non-logged in users the “free-entry” category.

This will only work if the conditional is inside the channel:entries tag. The tag uses the “contains” *= operator to search through the list of categories for the one you want.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.