Entry access
This add-on enables you to restrict access to certain channel entries for certain members.
Usage
If you want to restrict access to your entry, go to 'Entry access' tab that is shown to you when entry is created or edited. There, select all member groups and/or individual members whom you want to grant permissions to view the entry. Author and superadmins will always get access. If you don't select anything, no restriction will apply.
If you have more than 100 members on your site, the select control will use AJAX to fetch members. Enter at least 3 characters from the screen name into input above the members list and all matches will be shown.
You can specify default members and member groups that will be assigned to access an entry when it is created in extension settings.
The restrictions also work on backend, restricting editing the entry only to assigned members/groups (if set). No action required from you to get his work.
You can use {exp:entry_access:members} tag to display all members who have access to certain entry.
Tag parameters:
- entry_id — ID of entry. Required
- custom_fields="yes" — if set to "yes", will also parse custom profile data for members
Single variables:
- member_id
- username
- screen_name
- and other standard member profile fields
- Additionally, if you have custom_fields="yes" set then all custom profile fields are parsed.
To make the permissions work, you'll need to use two new tag pairs within {exp:channel:entries} call.
Wrap the actual content to be displayed into {grant_access} tag pair.
Wrap the text to be displayed if user does not have permissions to {deny_access} tag pair.
Example
{exp:channel:entries}
<p>This is text displayed to everyone</p>
{grant_access}
<h1>{title}</h1>
{body}
{/grant_access}
{deny_access}
<p><strong>You don't have access to {title}</strong></p>
{/deny_access}
{/exp:channel::entries}