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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kurt
    Member
    • Jan 2018
    • 37

    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.
  • tanya
    Senior Member
    • Jun 2014
    • 4308

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

    Comment

    • Kurt
      Member
      • Jan 2018
      • 37

      #3
      That worked, thanks.

      Comment

      Working...