There are a selection of helpers in Ghost Handlebars themes that help to scope content to your members. The following sections explain these helpers and provide examples of how they can be used.

Content

Any member that arrives on your site will have an access level attached to them. To correspond, all posts have a visibility setting attached to the content. This setting is applied when you select a post access level.

If the member's access matches, or exceeds, the access level of the post they will be able to view the content of the post.

access

access is a variable that is calculated between the access level of the member viewing the post and the access level setting applied to the post. access will return true if the member's access matches, or exceeds, the access level of the post.

Access example

{{#post}}
  <h1>{{title}}</h1>

  {{#if access}}
    <p>Thanks for being a member...</p>
  {{else}}
    <p>You need to become a member in order to read this post... </p>
  {{/if}}

  {{content}}

{{/post}}

@member

The @member helper can be used to scope anything in the theme to only people who have become a member of the site. To scope parts of a theme to members only use an #if statement in the following fashion:

{{#if @member}}
  <p>Thanks for becoming a member πŸŽ‰</p>
{{else}}
  <p>You should totally sign up... πŸ–‹</p>
{{/if}}

Additionally, @member can be used to check for paying members as well. @members.paid will return as true if the member has become a paying member:

{{#if @member.paid}}
  <p>Thanks for becoming a paying member πŸŽ‰</p>
{{/if}}

These two boolean values can be used in conjunction to customise UI and messages within a theme to particular audiences:

{{if @member.paid}}
  <p>Thanks for becoming a paying member πŸŽ‰</p>
{{else if @member}}
  <p>Thanks for being a member πŸ™Œ</p>
{{else}}
  <p>You should totally sign up... πŸ–‹</p>
{{/if}}

visibility

The visibility helper is relative to the post, or page, and is useful for providing templates with extra attribute information depending on the viewer status. visibility has 3 possible values: public , member or paid .

visibility examples

<article class="post post-access-{{visibility}}">
  <h1>{{title}}</h1>
  {{content}}
</article>

An example use case could be to show a particular icon next to the title of a post:

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

visibility in posts

Posts flagged for members only won't be shown when using #foreach with the posts helper. To show all posts, including members only posts, use the visibility="all" flag:

{{#foreach visibility="all"}}
    <article>
      <h2><a href="{{url}}">{{title}}</a></h2>
    </article>
{{/foreach}}

While this flag will show members only posts in the posts list the {{content}} of the posts will still be restricted to members.