Forums

dropdown users from a group joomla

ideagrup 07 Apr, 2015
Hi friends.

I'm trying to read the users of a group for one dropdown.

I need a relation between users and usergroupmap but with a new option relation into dbread is not posible.

Then i would like to create a custom code in setup ONLOAD that puts users in array with model for to read with dropdown.

Like this
[Users&groups]
[0]
[id] = 43
[name] = Tom
[group] = 53
[1]
[id] = 29
[name] = Paul
[group] = 53
the sql is this and running ok in mysql

SELECT `u`.`id`,`u`.`name`,`g`.`user_id`,`g`.`group_id` FROM `w47fa_users` AS `u`, `w47fa_user_usergroup_map` AS `g` WHERE `u`.`id` = `g`.`user_id` AND `g`.`group_id` = 53
Is posible?? have you a sample?

thanks

THOMAS
GreyHead 09 Apr, 2015
Hi Thomas,

I think that this should do it.
$db =& JFactory::getDBO();
$query = "
    SELECT `u`.`id`, `u`.`name`
        FROM `w47fa_users` AS `u`, `w47fa_user_usergroup_map` AS `g` 
        WHERE `u`.`id` = `g`.`user_id` AND `g`.`group_id` = 53 ;
";
$db->setQuery($query);
$form->data['user_list'] = $db->loadAssocList();
?>
Then you can use user_list as the Model ID, and id and name for the Dynamic settings.

Bob
This topic is locked and no more replies can be posted.