• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Create Article Plugin

Create Article Plugin 5 years 9 months ago #39358

On my RSForm, I'd like to set the category ID based on the user group (so if a user belonging to the Joomla Group "Location 1" is viewing the RSForm, I'd like to return only one category ID (the category into which that user group is allowed to submit articles).

How can I do this? I think I need a Hidden Field, but I'm struggling to figure out how to write the case condition to check the user's Joomla Group, and return the appropriate category ID.

SOLVED:
I used this code:

//<code>

$db = JFactory::getDbo();
$user = JFactory::getUser();

//Create a query to grab the group id of the currently logged in user

$db->setQuery("SELECT `group_id` FROM #__user_usergroup_map WHERE `user_id`='". $user->get('id')."'");
$gid = $submissions = $db->loadResult();

//Define the scenario, for example Super User group id = 8 and Registered = 2
if ($gid == 13){ return '71'; }
elseif ($gid == 24){ return '72'; }
elseif ($gid == 22){ return '73'; }
elseif ($gid == 26){ return '14'; }
elseif ($gid == 40){ return '90'; }
elseif ($gid == 25){ return '74'; }
elseif ($gid == 23){ return '75'; }
elseif ($gid == 21){ return '76'; }
//</code>
Last Edit: 5 years 9 months ago by alexander.block. Reason: Added solution
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!