1

I know I can restrict template output to Admins only with :

{% if currentUser.admin ?? false %}

…and to any logged in user with:

{% if currentUser ?? false %}

And I’m aware of accessCp as a permissions handle.

Can I use that, or similar, to restrict template output to any user group that is allowed to access the CP – without having to cycle through specific user groups in the template?

I tried:

{% if currentUser.accessCp ?? false %}

…but that doesn't work.

I'm using Craft 3.1.29.

2

I’ve figured out what I was missing. I needed to use can:

{% if currentUser.can('accessCp') ?? false %}

:)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.