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.

1 Answer 1


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

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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