eZ Community » Forums » eZ Publish 5 Platform » Find user has role
expandshrink

Find user has role

Find user has role

Tuesday 28 October 2014 8:03:47 pm - 3 replies

I have tried $roleService->getRoleAssignmentsForUser($user); but it returns an empty list.

How do I get what roles the user has?

Wednesday 29 October 2014 8:03:06 am

Hi,

 

you probably (hopefully), just need to set second argument to true to also take inherited roles into account, otherwise your asking about roles assigned to the user (directly), as opposed to it's user group (inherited, and normal best practice on modeling your roles assignments).

However it seems this was never added to interface (API), we should most likely do that:
https://github.com/ezsystems/ezpublish-kernel/pull/1056

If you don't have time to wait for this fix to reach a release, you can do this also by iterating users UserGroups and load their Roles.

Modified on Wednesday 29 October 2014 8:04:08 am by André R

Wednesday 29 October 2014 12:32:45 pm

I had to use a legacy callback for this, as the 5.x stack didn't return all the data I needed:

I also didn't test whether inherited roles are returned, as Andre suggested.

Modified on Wednesday 29 October 2014 12:33:09 pm by Gareth Arnott

Wednesday 29 October 2014 3:12:50 pm

Thank you I have applied the fix.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from