By NathanielTX on
I have a form that needs to have a person's name selected to assign a task to them. All the people who may be selected are in a particular Drupal role. What is the best way you can think of to have the members of a particular role offered as options on a drop-down select list?
I've seen http://drupal.org/node/492288 and it seems to be a way to grab stuff directly form the database for a select list, but I'm not good enough at SQL queries to even modify this to successfully list users from the database.
$options = array('' => t('- Name -'));
$res = db_query('SELECT DISTINCT name FROM 'users'');
while ($o = db_fetch_object($res)) {
$options[$o->name] = $o->name;
}
return $options;
I've thought about using a CCK node reference, but then I don't know how I would filter the user nodes that only have a specific role.
Any ideas?
Comments
_
A cck nodereference field would only work if you've somehow related users to nodes. cck userreference fields list users and you can use a view to limit the list to a particular role.