Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Group checking in twig

Started by David Lannan 9 years ago · 1 replies · 921 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 jeremycherfas, 1 week ago
4 172 1 day ago
General · by lynbor, 5 days ago
2 112 2 days ago
General · by Old Man Umby, 1 week ago
1 96 1 week ago
General · by Sebastian, 1 week ago
1 120 1 week ago
General · by Andy Miller, 3 weeks ago
0 245 3 weeks ago