Calc Builder Support

Calc Builder support
Public write access is disabled. Please login

Codes for retrieving group information of logged in users 11.11.2018 19:55

In your tutorial you mention the next code.

$usergroups= $user->groups; // List of Joomla groups this user belongs to (is an array)

Can you help me with the right code to retrieve or recover the data of this array of the list of groups the user belongs to.

We have assigned our customers who have registered on our site to different groups like customergroup1, customergroup2 .. ectera. Each customergroup has a different discount percentage. I am looking for the right code to find out to which group the logged-in user belongs to after the code $usergroups= $user->groups; and give him/her a certain discountpercentage when he/she uses our calculator.

Which PHP code do I have to use? Do I need column or row names? And if yes how to find these names in the array.

Best regards

Re: Codes for retrieving group information of logged in users 12.11.2018 10:01

that specific code will give you a collection of identifiers of the groups the actual user belongs to. So you will have at


, the group number of the first group assigned, at $usergroups[1]
the id number of the second group assigned, etc.
You can check if the user belongs, for ex, to group 8, using in_array function

//the user belongs to group 8

you could also loop through all array values using for/foreach expressions

foreach($usergroup as $group){

//code here for the group id $group

Hope this helps, regards
Moonsoft Team
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Our clients' feedback