function sharedemail_subuser_user in Shared Email 6
Implementation of hook_user().
File
- modules/
sharedemail_subuser/ sharedemail_subuser.module, line 49 - Integrate Subuser and Shared Email modules.
Code
function sharedemail_subuser_user($op, &$edit, $account, $category = array()) {
switch ($op) {
case 'update':
// Update email addresses of subuser accounts to match parent account.
// Only do this on parent account request. No need to update subusers
// on 'insert' because subuser accounts would not exist yet.
$subusers = subuser_get_subusers($account->uid);
if (empty($subusers) || !$edit['sharedemail_mail_sync']) {
return;
}
$sql = "UPDATE {users} SET mail='%s' WHERE uid=" . implode(' OR uid=', $subusers);
if (db_query($sql, $edit['mail']) !== FALSE) {
drupal_set_message(t('Subuser accounts updated to email address !mail', array(
'!mail' => '<em>' . $edit['mail'] . '</em>',
)));
}
break;
}
}