function workbench_email_get_users in Workbench Email 7
Same name and namespace in other branches
- 7.3 workbench_email.module \workbench_email_get_users()
Returns user array if they have a certain role.
Parameters
int $rid: The role ID
Return value
users Returns an array of users or an empty array
1 call to workbench_email_get_users()
- workbench_email_create_form_element in ./
workbench_email.module - Create the email selection form element.
File
- ./
workbench_email.module, line 542 - Code for the Workbench Email Module.
Code
function workbench_email_get_users($rid) {
$uids = array();
$query = db_select('users_roles', 'ur')
->fields('ur', array(
'uid',
))
->condition('ur.rid', $rid);
$query
->distinct();
$result = $query
->execute();
foreach ($result as $row) {
$uids[] = $row->uid;
}
$users = array();
$users = user_load_multiple($uids);
return $users;
}