Return to Snippet

Revision: 24992
at March 17, 2010 12:54 by jonathanpglick


Initial Code
function _get_emails_by_role( $role ) {
    $q  = "SELECT u.mail AS email ";
    $q .= "FROM {users} u ";
    $q .= "INNER JOIN {users_roles} ur ON u.uid = ur.uid ";
    $q .= "INNER JOIN {role} r ON ur.rid = r.rid ";
    $q .= "WHERE r.name = '%s';";
    $db = db_query($q, $role);
    $emails = '';
    while ($row = db_fetch_object($db)) {
	$emails .= $row->email . ', ';
    }
    return $emails;
}

Initial URL

                                

Initial Description

                                

Initial Title
Drupal - get email addresses by role

Initial Tags

                                

Initial Language
PHP