Hide "member only" posts on index page if not connected

Hello

Is it possible I would like to hide “member” posts from the index page if the user is not connected?
Or at least, if it’s not possible, add a “lock” icon on those posts

Thanks

It is possible to make this configuration in your theme.

First of all, make sure that all posts are displayed, by looking for the foreach statement in the index.hbs. It is explained in the “visibility in posts” section on the membership documentation page:

Posts that are set to members-only or paid-members only won’t appear in post archives unless the visibility="all" flag is included with the #foreach helper:

Next, you can use the visibility helper to create a custom CSS class for the non-public posts and create a style that introduces the lock icon. You can find this use case in the “visibility” section on the membership documentation page

<svg>
    <use xlink:href="#icon-{{visibility}}"></use>
</svg>
1 Like

thanks @pieter! I just tried to play with parameters.

But if I remove/change the visibility tag, members posts will disappear for everybody, even the connected members.

What I would like, if possible is to put in the index.hbs something as:
if user is a member
see post

Is this possible?

Thanks for your help @pieter!

I updated index.hbs file with in order to display all articles for connected members and public articles for not connected members:

   <div class="post-feed">
        {{#if @member}}
            {{#foreach posts visibility="all"}}
                {{> "post-card"}}
            {{/foreach}}

        {{else}}
            {{#foreach posts }}
                {{> "post-card"}}
            {{/foreach}}
        {{/if}}
    </div>
1 Like