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.

Dan Owen
  • 496
  • 2
  • 12

1 Answers1

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.

Marion Newlevant
  • 12,047
  • 22
  • 55
Dan Owen
  • 496
  • 2
  • 12