Using GRAV Group-Based Permissions

Upon login, we wanted to present users with just the directories and pages they had access to.
In order to do this, we used GRAV group-based permissions.

First we must modify sidebar.html.twig to display the folders/pages only if the user’s group matches the client in the folder/page header.

Using GRAV admin panel Editor plugin, navigate to sidebar.html.twig and insert the boxed line below:

 

The next step is to create a group and assign permissions to the group. Once this group is made, users can be assigned to the group and will inherit the permissions. This will make the pages only viewable to users with this custom permission. This prevents random users from going to the URL to view the page.

Add a user/config/groups.yaml file with something like this:

cda:

  readableName: ‘CDA’

  description: ‘The group of premium members’

  access:

    site:

      login: true

      cda: true

The user given access must be given group assignment and have site.login set to YES:

 

Once this is done, we can make pages/folders just for this group by creating new folder/page and going to “Expert” section.

For folder/directories, place this in the Expert Frontmatter:

taxonomy:

    client:

        – CDA

For pages, place this in the Expert Frontmatter:

taxonomy:

    client:

        – CDA

access:

    site.cda: true