Skip Navigation

Creating templates to display members-only content in WordPress

Your site might have content reserved only for members. In this case, you need to display some teaser content to the visitors and whole content to the logged-in users. Toolset lets you design both of these templates and set which one to display for different types of users.

Here’s an example of a membership site that offers video tutorials only to members.

Logged-in members see full content

Visitors see only partial, teaser content

Follow these steps

To create two templates, one for site members and one for visitors, you’ll need to install the Toolset Access plugin (in addition to Toolset Types and Toolset Blocks)

Here is an outline of what you need to do:

  1. Create two templates – a template for members with the full content and a template for visitors with teaser content
  2. Use Toolset Access to set the template with a teaser to be displayed to visitors
  3. Design the content of both templates

Let’s go through these steps one by one.

Create the templates for logged-in users and for visitors

  1. Go to Toolset → Dashboard and click the Create Content Template button in the row of the post type you want to design a template for.
  2. Go to the Toolset Content Templates page and click the Add New button at the top.
  3. Give a clear name to this template, something like “Teaser template for visitors”.
  4. Don’t assign this template to any content and click to create it.

You can leave both templates mostly empty. We’ll get back to designing them in a minute.

Display the teaser template only to visitors

Now, let’s change the access settings so that visitors see only the teaser template when they visit our posts.

  1. Go to Toolset Access Control. All the post types in your site are listed here.
  2. Click to expand the post type with your premium content. A table appears listing all user roles in your site and their permissions for this post type.
  3. Under the Guest row, deselect the checkbox in the Read column. This means that visitors who are not logged in cannot view the default template for this content type.
  4. Click the pen icon that appeared next to the checkbox you deselected. A pop-up dialog appears with options to select what to display for users with no read permission.
Pop-up dialog with options for when the user has no read permissions
  1. In the first section, select the Show Content Template option. In the dropdown menu, select the teaser template you created.
  2. In the second section, select the option to choose a different WordPress archive. In the dropdown menu, select the archive of your preference. This works the same as with templates. In our example, we display the same archive to all users. If needed, you could design a special “teaser archive”, just like for the templates.

Designing the templates

Now that we have two templates, it’s time to design them. The template for members will include the full content that you want site members to see.

  1. You can access both your templates from the Toolset Content Templates page.
  2. Edit them and use the WordPress Block Editor to design your template.
  3. Choose blocks from the Toolset section for any part of the template that displays fields (not static elements). For example, use the Toolset Heading block for any heading that will display a field.
  4. Enable Dynamic Sources for blocks that should display fields of the post that the template displays.

Template Design Tips

  • Use the View with dropdown menu at the top of the editor to preview your template with any post of your choice.
  • Use the screen-size selector either at the top of the editor or next to different fields to design the template for different screen sizes.
  • Use the View block to display lists of related posts or repeating field groups.

Change the Layout of a Template

Theme defines the basic layout of single-post pages on the site. This includes options like the width of the page, displaying of sidebar and the page title, and more.

Using one of the themes integrated with Toolset allows you to control the layout of the single-post template. You can set different layout options for different templates.

If your theme is integrated with Toolset use the following steps to change the layout options:

  1. In the right sidebar, click the Document tab.
  2. Expand the Toolset settings for… section (the last part will be the name of the active theme).
  3. Tweak theme options as needed.

Please note that different themes provide different options.

If your theme is not integrated with Toolset, you might try changing the layout options from the Appearance → Customize page, or from the theme’s own settings page.

Displaying a YouTube Video Coming from a Custom Field

Toolset allows you to easily display YouTube videos whose URL comes from a custom field. Additional advantage of using the Toolset YouTube block is that it offers an array of video settings options like the width, aspect ratio, start/end time, autoplay, and more.

Use the following steps:

  1. Edit your template and insert the Toolset YouTube block.
  2. Click Yes to use a Dynamic Source.
  3. Use the dropdowns to select the custom field that holds the YouTube URL information.
  4. In the right sidebar, use the Video Settings section to set custom options for displaying the YouTube videos.

Using Toolset YouTube block to display a video coming from a URL saved in a custom field
Using the Toolset YouTube block to display a video coming from a URL saved in a custom field

Updated
November 18, 2020