Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Group checking in twig

Started by David Lannan 9 years ago · 1 replies · 983 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 Andy Miller, 6 days ago
0 108 6 days ago
General · by lynbor, 1 month ago
3 437 2 weeks ago
General · by lynbor, 3 weeks ago
7 557 2 weeks ago
General · by Harry, 2 weeks ago
0 159 2 weeks ago
General · by Old Man Umby, 1 month ago
2 308 3 weeks ago