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

Group checking in twig

Started by David Lannan 9 years ago · 1 replies · 889 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 jean-louis67, 3 weeks ago
2 307 3 weeks ago
General · by Andy Miller, 3 weeks ago
0 310 3 weeks ago
General · by Veehem, 4 weeks ago
0 263 4 weeks ago
General · by milkboy, 4 weeks ago
0 264 4 weeks ago
General · by ian russell, 1 month ago
2 335 1 month ago