Set page access level within the template?

How would I set a custom .hbs template’s page access level within the code of the page itself? How do I set it directly without doing it in the Ghost dashboard?

For example, I have a custom template something.hbs, and I want its page context to be paid members only so that I show different things based on the {{access}} variable. How do I set out that outside the Page dashboard?

A caution here that if you don’t set the post content restrictions on the post itself, the Content API won’t know about them, and so your content will be accessible.

You can definitely change what the template shows based on access, but be warned that you probably want to set the access to something restrictive, too.

There are some examples of using membership status here:

Some good discussion here:

1 Like

Thanks @Cathy_Sarisky. That’s very helpful. So the conditionals should be on the member object. not on access itself.

Depends on your exact case - this example does use access:

1 Like