Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Group checking in twig

Started by David Lannan 9 years ago · 1 replies · 753 views
9 years ago

I havent been able to find much information about how to use group authorization in twig.
Pseucode I would like to do:
{% if 'some group is authorized' %}
Authorized portions of the site
{% endif %}

The authorize function seems to only work for admin and user control.
Any help would be greatly appreciated.
Cheers,
Dave

9 years ago

I think I have figured it out.
In the Admin Addon User Manager plugin settings, you need to add custom permissions.
I added a series of new persmissions that matched my group ones: group.manager, group.developer etc
Then in the twig I could use authorize like:
{% if authorize( ['group.manager'] ) %}
blah
{% endif %}
This seems to work reasonably well, and you can have multiple groups in the authorize list. The only thing is that it doesnt directly map to the groups I had created in my Groups Manager. So Im still working out how to best do that.
Hope this helps.

👍 1

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 76 8 hours ago
General · by pamtbaau, 13 hours ago
1 47 12 hours ago
General · by Andy Miller, 1 day ago
0 44 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago