By Ebenezer on
I am looking for PHP code to get all users by a certain role.
Here is a sample piece of code. I don't know how to add to it the condition that all user should only be of a certain role.
$result = db_query('SELECT users.uid AS uid,
users.mail AS users_mail,
users.name AS users_name
FROM users users');
while ($existing_user = db_fetch_object($result)) {
print_r($existing_user); // or do whatever
}
I'd appreciate your help!
Comments
Looking for the same thing!
I'm also looking for a php snippet to list users of a certain role.
Thanks.
Subscribing..
+1
Get all users by role id / role name
Get all users belonging to a role by the role's name:
Get all users belonging to a role by the role's id: