Skip to content
Content

Members-only content

Keep pages for people with an account, a role or a purchase, and show everyone else a teaser.

On this page

Some pages are for members only: a magazine's articles, the lessons of a course, a client area. Lettern can keep them for the people who have access, and show everyone else the start of the page with a way to read on.

This needs visitor accounts, turned on under Settings → Users → Sign-Up, so visitors can sign up and sign in. Once they're on, every page, and every other entry with its own address, has a Who Can Read This setting.

#Choose who can read a page

Open the page's details on the right, find Who Can Read This, and pick an Access:

AccessA visitor who isn't signed inSigned in, without accessWith access
EveryoneReads itReads itReads it
Everyone Reads the StartReads the start, then how to read onReads the start, and a noteReads it
Only People with AccessIs sent to sign in, and backIs told they have no accessReads it
Same as AboveFollows the page above it

Your team can always read every entry in a collection they're allowed to see.

#Lock a whole collection

Open the collection under Collections (in the sidebar's Design section), choose its Settings tab and set Who Can Read This there. It applies to every entry that doesn't say otherwise.

That's what Same as Above means: an entry follows the version it was translated from, then its parent page, then its collection. So a course locks all its lessons in one place, and one free lesson simply says Everyone.

#Choose who has access

Under Who Has Access, list the words that open the page: role names, or access names you make up, like magazine or course-php. Leave it empty to let in anyone with an account.

To give someone an access name, click them in Settings → Users, add it under Access and press Save. Plugins can give them too, for example after a purchase, and optionally until a date. See Using accounts.

#Show a teaser

With Everyone Reads the Start, visitors see the page up to a Teaser Ends Here block, or up to the number of Words in the Teaser (120 unless you set it), whichever comes first. Blocks are kept whole: one that doesn't fit is left out.

The entry's other fields stay hidden, unless you name them under Fields in the Teaser, like excerpt. SEO fields always stay public, because they're written to be seen.

#What stays hidden

The rule holds everywhere Lettern shows content, not just on the page itself:

  • Locked pages are left out of lists, related entries, feeds, the sitemap and site search for anyone who can't read them. A link or menu item someone added by hand stays visible: it's a page you're meant to find, and sign in for.
  • Teasers appear in lists and the sitemap with only their public part.
  • Members-only pages are never saved as plain files. They're made for each visitor, and never cached.

#For developers

#In the collection file

YAML
gate:
  mode: teaser          # public, teaser or locked
  access: [magazine]
  teaser_words: 120
  teaser_fields: [excerpt]

An entry stores the same object in its gate field; mode: inherit (or no rule) is Same as Above. The setting is added to every collection with its own URLs while visitor accounts are on.

#Where it's enforced

The rule is enforced where entries are read, so it holds for every way in:

  • Locked entries are left out of lists, relations, feeds, the sitemap, the search index and the Delivery API for anyone who may not read them.
  • The API marks teasers "gated": true. Searching, filtering or sorting by withheld text skips them.
  • A gated page is never a static file: it renders per person, no cache may keep it, and gating a published page removes its file at the next build. Markdown versions are not published for gated pages.
  • With accounts off, or the Users module off, the rule still holds: a locked page answers 404, and a teaser stays a teaser.