Buy Now
Sign in

Dynamic Drop Down - Users > Filter by Access Group - how?

BrettVorster , January 18 2013
B
BrettVorster

Hi Guys,

I'm here as I need some help. I'm pleased to say I figured out how to pull in data from the database, in this instance just pulling in all the users (into a drop down) and then outputting their usernames. I now need to filter this so that it only shows the users from usergroup id=2 could someone help me, with a step by step guide on how to do this?

Thank you
Brett

GreyHead

Hi Brett,

If this is Joomla! 1.6 or later then I think that you have to use a compound query - look in the #__user_usergroup_map table for a list of user_ids with group_id = 2, then look up the user info for those users in the #__users table.

This can be done with linked DB Multi-Record Loaders, but if you are OK with MySQL it might be just as easy to hand-code it.

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

B
BrettVorster

Hiya Bob,

I'm on 2.5 for this one, the mysql thing is a rabbithole for me at the moment - I've got a few Multi-Record Loaders in place already that I'm using to bring in some other stuff from the database + the one I'm using for the dynamic drop down of the users, so maybe that route. I know you must be really busy with a million other things as the forum is really big but if you could help me with some code or directions on where to find something I can apply that would be great

admin

Hi Brett,

First of all, its not wise to pull all users in 1 query, if you have a big number of users in your database then this query may knock off your database server or cause severe performance issues.

So you have a dynamic dropdown loading a list of users through a "db multi record loader" action ? and you want to load users under specific group id ?

you will need 2 record loaders associated together, 1 for the "users" table, another for the "user_usergroup_map" table, the "user_usergroup_map" table will be the main model, the other will be the "associated" model, you can check the action configuration and few posts here on the forums on how to associate the 2 models together, you just need to set the models ids, and set the join rule.

Regards,
Max

Max
If your main question got answered then please mark the answer using the button!