function workbench_email_get_users in Workbench Email 7.3
Same name and namespace in other branches
- 7 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_get_all_transition_users in ./
workbench_email.module - Returns all available users for an email transition.
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');
$query
->join('users', 'u', 'u.uid = ur.uid');
$query
->fields('ur', array(
'uid',
))
->fields('u', array(
'status',
))
->condition('ur.rid', $rid)
->condition('u.status', 1);
$query
->distinct();
$result = $query
->execute();
foreach ($result as $row) {
$uids[] = $row->uid;
}
$users = user_load_multiple($uids);
return $users;
}