I would like to send results of a webform to all users of a certain role. (recipients are all users of a role)

Does anyone have simple solution for this?

Comments

dids’s picture

Subscribing

bocky’s picture

Found code to get all email addresses of users of a role. I put it in markup field and it shows addresses, however markup fields cannot be used as conditional recipients.

$myRole = "MyRole";

$roleSQL = "SELECT * FROM {users} WHERE uid IN (SELECT uid FROM {users_roles} WHERE rid=(SELECT rid FROM {role} WHERE name='%s'))";
$roles = db_query($roleSQL, $myRole);
while($role = db_fetch_array($roles)) {
  $usersinrole[] = $role['mail'];
}
if(count($usersinrole) > 0) {
  print implode(",",$usersinrole);
}

Is it possible to add recipients with some additional processing code?

AmitV-2’s picture

Subscribing

quicksketch’s picture

Status: Active » Closed (fixed)

This would almost certainly require custom PHP to accomplish. Support for writing custom submit handling code (which is what this would require) is not provided in the Webform queue.