Access Restrictions/Paywall
There are a couple of options in dealing with a user who attempts to access content that they don't have access to (because it is restricted to a member group that they are not in).
- In standard modules, by default, the paywall.thtml template is displayed. However, this auto-paywall functionality can be disabled in the control panel at Configuration > Paywall.
- Within your templates, you can use the {restricted} template plugin to detect the user's member group status and display/not display content accordingly. This is all within your active template file.
In addition to displaying/not displaying HTML content using the above techniques, you may also wanted to protect file downloads from being shared. For this, you should use the {protected_link} template plugin documented in the global plugins documentation.
Using the Auto-Paywall
Your Paywall settings are configured at Configuration > Paywall in the control panel.
The "Paywall" comes in to play when a user stumbles upon a piece of content which they do not have permissions to see. By default, your site will be using the Auto-Paywall. This means that, when your user hits this content, they will be directed to a site-wide-standard Paywall page generated by a standard template file in your theme. This template file is customizable but defaults to paywall.thtml.
You can customize this template file to have your own marketing text or a customized login form and registration link, but many sites will likely keep it as is.
Alternatively, you can turn off the Auto-Paywall and deal with content permissions manually, using the {$privileges} array returned by all standard content.
Showing Partial Content in the Auto-Paywall Template
Hero's modules will send their content to the paywall template in the $content array. So, if you want to display or use this content in any way, you can do so in the paywall template.
For example, if you want to show the title of the content they cannot see, you would have this code in your paywall template:
<p>Hey! You just tried accessing <u>{$content.title}</u>! Unfortunately, you don't have access to do this.</p>
<p>Please <a href="{url path="users/login"}">login</a> or <a href="{url path="subscriptions"}">subscribe</a> to view
the content.</p>
You might also want to show a part of the content. In the following example, there is a field called "Body" which holds the body of the article:
<h1>{$content.title}</h1>
<p>Here's a 500-character preview of the article you tried to read:</p>
{shorten length="500" string=$content[body]}
<p>Want to read more? <a href="{url path="users/login"}">login</a> or <a href="{url path="subscriptions"}">Subscribe</a>!</p>
Detect Content Type in Auto-Paywall
The auto-paywall may receive redirects from content pages, forms, blogs, etc. If you want to change the page depending on what content type is being restricted, you can access the $type variable.
For example:
{if $type == 'content'}
You were accessing an article, {$content.title}.
{elseif $type == 'form'}
You tried to submit a form, {$content.title}.
{/if}
Manually Detecting Access Privileges
If you disable the paywall, you will need to use code similar to the following in your content template to protect the content:
{if $logged_in}
{restricted in_group=$privileges}
The user is in the group. They will see the content
{/restricted}
{restricted not_in_group=$privileges}
The user cannot see the content because they are not in the proper groups.
{/restricted}
{else}
Please <a href="{url path="user/login"}">login now</a> to see this content.
{/if}