I have a CFv6 form at https://dev.mission-bbq.com/restaurant-visit-notes that features a "Location" select field. I am going to have multiple users using this form, but want each to only be able to select from a different set of locations.
How can I set the list of options in the select field to display different options based on the user id? Or, if simpler, by the Joomla group that the user is assigned to?
Well do you have the user id stored somewhere in the database? As in, how are you linking the user id to the list of allowed locations? And yes it probably would be easier to use the group id.
Right now I am starting from scratch. I just have a simple form with no PHP or JS added. That's what I'm looking for help with.
What code would I need to add to read in the group id of the user? What I'm looking to do is display different select field options to different user groups. For example:
If the user is in the group called "Region 1" then the select field options would be: Location 1, Location 2, Location 3
If the user is in the group called "Region 2" then the select field options would be: Location 4, Location 5, Location 6
etc.
User group membership is stored in user_usergroup_map
Hi sjkelly,
Please check the Joomla docs, there is a JUser class method that will return an array of user groups for a given user I'd.
Bob
I'd you look at {user:} one of the parameters available to you is an array of group IDs the user is in