Custom layouts for archives with restricted access: a practical application of our new Access feature

January 16, 2018

Imagine the following.

Adam offers some training courses. He uses a WordPress site for these courses and custom post types.

Adam’s courses are available only to users who have purchased a membership plan. However, Adam would like to attract new customers as well. For this reason, for each course, he wants to show the course image and a post excerpt for anybody, including visitors, to view.

The following screenshot shows how he wants his courses page to appear for any site visitor:

How Adam wants his courses page to appear for any site visitor
How Adam wants his courses page to appear for any site visitor

However, when someone clicks on a course, Adam wants that person to see the following page:

Single course page with restricted access
Single course page with restricted access

Simultaneously, users who have access to the site (i.e., members) can see the post content:

Users who have access to the site (i.e., members) can see the post content
Users who have access to the site (i.e., members) can see the post content

To protect his courses from unprivileged users, Adam uses the Toolset Access plugin for the Advance Tutorial post type. The Read option is left unchecked for Guests; therefore, unregistered visitors will not see these posts:

Protecting courses from unprivileged users by leaving the Read option unchecked for Guests
Protecting courses from unprivileged users by leaving the Read option unchecked for Guests

Question

How do we make only the post excerpt and images visible to guests on the course archive page?

The main fact is: if you restrict access for a certain post type, unprivileged users will see the “No posts found” message instead of the post type archive page. This makes sense, as access to the post type is forbidden for a specific reason. Still, how can we help Adam attract new customers? Potential customers must see something to become interested in his courses.

Solution

We must create an archive that shows only the post titles, images, and excerpts (or any content that will lure in prospective customers) and use it to display to users without read permission.

We can do this using the little pen icon on the Access screen:

Assigning a custom template layout for archive pages for which no read permission is required
Assigning a custom template layout for archive pages for which no read permission is required

When you click on it, the following pop-up dialog appears:

Show Template Layout -a new Access feature
Show Template Layout -a new Access feature

Since the Toolset Access 2.4.3.3 release, a new option appears on this screen, namely, Show Template Layout, which now works with any theme. It allows you to assign a custom template layout for archive pages for which no read permission is required.

If you are not using Layouts, you can instead assign a WordPress Archive created with Toolset Views.

Adam’s problem is solved. Adam is happy, as his page now attracts new leads. Potential customers are happy, as they can see Adam’s full offer before they buy.

We hope you too will be happy if this type of feature is needed for your Toolset project built with the Toolset Layouts and Access plugins. Our documentation for Toolset Access will assist you.