Announcement

Collapse
No announcement yet.

How to get the role of a user in a beforeSave hook

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get the role of a user in a beforeSave hook

    I'm trying to get the role of a user in a beforeSave hook. I can get the userId from the assignedUserId of the entity, and then use that to query for the user by ID, but I can't seem to find a way to get a list of roles or role names (I really need the latter) once I have a user. I expected something like $user->get('roles') or $user->get('rolesIds') to work but haven't had any luck.

  • #2
    Hello,
    if the field is not loaded, you can load it with the loadLinkMultipleField method

    Comment


    • #3
      That worked, thanks.

      Comment

      Working...
      X