0

I like to add the Group Role of the currently logged in user to the body class of the page twig template. So this is not the same as the user roles the user account has. Currently using Drupal 9.0.3. with the Group module.

I understand that for user roles, it is

{% set roles = user.getroles(TRUE) %} {{ dump(roles) }}

But what is it for Group Roles?

  • 3
    Not that simple, first get the group the user belongs to. Once you have the group, you can get the role. – No Sssweat Aug 18 at 13:01
  • To add to this, content can be in multiple groups and a user can have different roles in different groups. – sonfd Aug 18 at 22:13

Your Answer

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

Browse other questions tagged or ask your own question.