2

I'm trying to check if a user is part of a user group but not having any success! I tried this:

{% if entry.author.groups == 'authors' %}

But even though the user is definitely in a user group with that handle, the output inside that if statement doesn't show up.

I also tried this:

{% if entry.author.admin != 1 %}

That DID work, but unfortunately i don't just want to check if the user is not an admin, i want to specifically check their user group.

2
  • maybe you can find your answer here? questions/1087 Jan 23, 2015 at 16:46
  • Ah, spot on Fabio! I feel a bit foolish that i somehow missed the isInGroup method. My code now looks like this: {% if entry.author.isInGroup('authors') %} And works like a charm!
    – Dan Owen
    Jan 23, 2015 at 16:51

1 Answer 1

5

As Fabio pointed out, i'd managed to miss the isInGroup method. Slightly embarrassing!

So for anyone else looking to do what i asked, i changed my code to the following:

{% if entry.author.isInGroup('authors') %}

and it works perfectly now.

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.