Template Tags

Last updated: November 2nd 2024

You can check weather the entry is restricted or not just by passing that entry ID through this code {exp:super_restricted_entries:check} . This code has only 1 parameter which is required. Parameter is entry_id

Example 1: (Check if granted)
{exp:channel:entries channel="blog" url_title="{last_segment}" require_entry="yes"}
    {exp:super_restricted_entries:check entry_id="{entry_id}"}
    {if super_restricted_entries:granted}
        <p> <strong>Granted: </strong>{title}<br></p>
    {/if}
    {/exp:super_restricted_entries:check}
{/exp:channel:entries}
Example 2: (Check for not granted)
{exp:channel:entries channel="blog" url_title="{last_segment}" require_entry="yes"}
    {exp:super_restricted_entries:check entry_id="{entry_id}"}
    {if ! super_restricted_entries:granted}
        {redirect="404"}
    {/if}
    {/exp:super_restricted_entries:check}
{/exp:channel:entries}
Example 3: Mix example for granted and not granted:
{exp:channel:entries channel="blog" dynamic="no"}
    {exp:super_restricted_entries:check entry_id="{entry_id}"}
    {if super_restricted_entries:granted}
        <p> <strong>Granted: </strong>{title}<br></p>
    {if:else}
        <p> <strong>NOT Granted: </strong>{title}<br></p>
    {/if}
    {/exp:super_restricted_entries:check}
{/exp:channel:entries}

Fetch Restriction Information per entry

Added from v1.0.6

Alternatively, You can also use {exp:super_restricted_entries:fetch_entry_access} tag to fetch particular entry's group and member access infomration.

Channel Form example
{exp:channel:form channel="home" entry_id="21"}
    <input name="title" type="text" value="{title}">
    <input name="super_restricted_entries__member_access" type="hidden" value="">
    <input name="super_restricted_entries__group_access" type="hidden" value="">

    {exp:super_restricted_entries:fetch_entry_access entry_id="{entry_id}"}
        {!-- Code to create checkboxes for member roles and used fetch_entry_access's "super_restricted_entries:group_access" variable to set checked items --}
        {exp:query sql="SELECT role_id, name FROM exp_roles WHERE role_id not in ('1', '2', '3', '4')"}
        <label>
            <input type="checkbox" name="super_restricted_entries__group_access[]" value="{role_id}" {if super_restricted_entries:group_access ~ '/(^|\|)'.role_id.'($|\|)/'}checked{/if} />
            {name}
        </label>
        {/exp:query}

        {!-- Code to create checkboxes for members and used fetch_entry_access's "super_restricted_entries:member_access" variable to set checked items --}
        {exp:query sql="SELECT member_id, screen_name FROM exp_members WHERE role_id != '1'"}
        <label>
            <input type="checkbox" name="super_restricted_entries__member_access[]" value="{member_id}" {if super_restricted_entries:member_access ~ '/(^|\|)'.member_id.'($|\|)/'}checked{/if} />
            {screen_name}
        </label>
        {/exp:query}
    {/exp:super_restricted_entries:fetch_entry_access}

    <input type="submit" value="Submit">
{/exp:channel:form}