The following code illustrates how to access groups an user is subscribed with Joomla ACL. Groups ids are returned in an array
1 2 3 4 5 6 7 |
$user = JFactory::getUser(); $userId = $user->id; jimport( 'joomla.access.access' ); $groups = JAccess::getGroupsByUser($userId); print_r($groups); |
To test the code, do not forget to lougout and login again should you have modified the user group from the back-end
![Share on Facebook Facebook](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/facebook.png)
![Share on Twitter twitter](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/twitter.png)
![Share on Reddit reddit](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/reddit.png)
![Pin it with Pinterest pinterest](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/pinterest.png)
![Share on Linkedin linkedin](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/linkedin.png)
![Share by email mail](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/mail.png)