What is the preferred way of programmatically generating a list of users with a certain role?
(I know how to do it with a database query, but surely there's a higher-level method.)
What is the preferred way of programmatically generating a list of users with a certain role?
(I know how to do it with a database query, but surely there's a higher-level method.)
In Drupal 7, user_load_multiple($uids = array(), $conditions = array(), $reset = FALSE)
will load the user details for the given user IDs.
In Drupal 6, there isn't that function, but you can use $user = user_load(array('uid' => $node->uid));
.
SELECT u.* FROM users u,role r, users_roles ur WHERE r.name="authenticated user" AND r.rid=ur.rid AND ur.uid=u.uid;
try this query.
Umm? Create a view of type USER, filter on USER ROLE, and have field USER NAME?
user_load()
--- I don't have to directly query the database, nor do I have to build and execute a View --- resulting in code that's easier to maintain.
– smokris
Dec 12 '11 at 17:58