You are here

function messaging_mail_update_user in Messaging 7

Same name and namespace in other branches
  1. 6.4 messaging_mail/messaging_mail.module \messaging_mail_update_user()

Update destinations when a user account is updated, created.

The destinations for that mail account will be assigned to the user.

2 calls to messaging_mail_update_user()
messaging_mail_user_insert in messaging_mail/messaging_mail.module
Implements hook_user_insert().
messaging_mail_user_update in messaging_mail/messaging_mail.module
Implements hook_user_update().

File

messaging_mail/messaging_mail.module, line 90
Simple mail using Drupal API. Messaging method plug-in.

Code

function messaging_mail_update_user($account) {
  if ($account->status) {

    // Update mail for destinations of this user
    db_query("UPDATE {messaging_destination} SET address = :address WHERE uid = :uid AND type = 'mail'", array(
      ':address' => $account->mail,
      ':uid' => $account->uid,
    ));

    // Update uid for destinations with this mail
    db_query("UPDATE {messaging_destination} SET uid = :uid WHERE uid = 0 AND type = 'mail' AND address = :address", array(
      ':address' => $account->mail,
      ':uid' => $account->uid,
    ));
  }
}