function privatemsg_user_update

7-1 privatemsg.module privatemsg_user_update(&$edit, $account, $category)
7-2 privatemsg.module privatemsg_user_update(&$edit, $account, $category)

Implements hook_user_update().

File

./privatemsg.module, line 1404
Allows users to send private messages to other users.

Code

function privatemsg_user_update(&$edit, $account, $category) {
  if (isset($edit['pm_enable']) && (user_access('write privatemsg') || user_access('read privatemsg')) && user_access('allow disabling privatemsg') && privatemsg_allow_disable($account)) {
    $current = privatemsg_is_disabled($account);
    $disabled = (int) !$edit['pm_enable'];
    $edit['pm_enable'] = NULL;

    // Only perform the save if the value has changed.
    if ($current != $disabled) {
      // If disabled is 1.
      if ($disabled == 1) {
        // Insert the setting.
        privatemsg_set_setting('user', $account->uid, 'disabled', $disabled);
      }
      else {
        // Delete the setting.
        privatemsg_del_setting('user', $account->uid, 'disabled');
      }
    }
  }
}