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.
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.
Sign up to join this communityI 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.
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
<?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.