Plugin screenshot thumbnail 1/1

We've recently acquired this from the Superbig team. Read our blog post for more details.

This plugin provides an Field Type where you can select one or more user groups.

Configuring User Group Field

There is 3 display modes:

  • As a dropdown, where you can select only 1 group
  • As a group of checkboxes, where you can select 1 or more groups
  • As a group of radio buttons, where you can select only 1 group

Using User Group Field

To list the group(s) selected:

{% set groups = entry.userGroupFieldHandle.getGroups() %}
{% for group in groups %}
    {{ group.name }}
{% endfor %}

To get only the first group

{% set groups = entry.userGroupFieldHandle.getGroups()|first %}
{{ group.name }}

To check if the current user is in any of the groups selected

{% if entry.userGroupFieldHandle.inGroup(currentUser) %}
    <h1>User can access</h1>
{% endif %}

To check if the current user can access something based on the group selection

{% if entry.userGroupFieldHandle.canAccess(currentUser) %}
    <h1>User can access</h1>
{% endif %}

Note: This check is always true for admins.

Installation Instructions

To install this plugin, copy the command above to your terminal.

Active Installs
255
Version
3.0.1
License
MIT
Compatibility
Craft 3, Craft 4
Last release
August 3, 2022
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
0
Open PRs