I am trying to create vendor panel.

In that I need to identify the user is vendor or normal user.

For that I need to add session variable or variable in user object.

But how can I achieve that.

Help me to solve this issue.

  • Why not just create separate user groups called "Vendor" and "End-User" and assign the users to those appropriate groups? Aug 16, 2016 at 1:44
  • I did that, but after that how can I get that group name @MichaelYaeger Aug 16, 2016 at 6:29
  • if you want to check if a user is a member of a particular group, use: <?php $user = JFactory::getUser(); if(in_array(11,$user->groups)) /*Do something...*/; ?> where "11" is the ID of the group in question. The ID of the groups you are using can be found in the Administrator under Users > Groups. Aug 16, 2016 at 19:10
  • @MichaelYaegers answer is the correct method of determining a users group. Feb 10, 2017 at 21:00

1 Answer 1


According to this tutorial https://docs.joomla.org/How_to_use_user_state_variables it is quite simple

$mainframe = JFactory::getApplication();
$mainframe->setUserState("$option.state_variable", "state1");

Documentation of this function can be found here https://api.joomla.org/cms-3/classes/JApplicationCms.html#method_getUserState

Maybe for your case it's better to use set and get functions on the user's object. I've never used them, so I don't know if they are permanent or how exactly they behave. Check them here https://api.joomla.org/cms-3/classes/JUser.html#method_set

  • 1
    This is more for setting a userState variable. I think what the OP is looking for is how to get a users specific group. Feb 10, 2017 at 20:59
  • 1
    Yes you are right, the best solution would be to create "Vendor" group and then the specific access level, doesn't need to play with any state variables.
    – Adam M.
    Feb 13, 2017 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.