I have managed to return the user’s information by using the API like this:
$profile = $modx->user->getOne('Profile');
Following this I want to the get the user’s group role to find out if they are allowed to see certain parts of my snippet. I have tried all of the following but they don’t work
$profile->getOne('UserRole');
$profile->getOne('modUserRole');
$profile->getMany('UserRole');
$profile->getMany('modUserRole');
The getMany() lines return empty arrays, getOne() returns nothing. I would presume getMany() is likely to be correct as a user could be long to multiple groups and therefore multiple roles.
The user I am testing it on has the role of ’Moderator’ within a user group. I don’t need to know which group they are in, just the role (name or id) within it. Reason: All Moderators can update elements regardless of the group they are in.
Any idea? I have trawled the forums, the web and looked through Bob’s Guides but I haven’t found the answer as yet.
Any Ideas?