You are here

function advuser_user_ in Advanced User 7.3

hook_user implementation

On 'form' (indicates user edit form) save the account data in a static cache. On 'insert' call the registration notification function. On 'after_update' call the profile update notification function.

Related topics

4 calls to advuser_user_()
advuser_user_insert in ./advuser.module
advuser_user_load in ./advuser.module
advuser_user_presave in ./advuser.module
advuser_user_update in ./advuser.module

File

./advuser.module, line 325
Advanced user module allows you to select users based on an advanced set of filtering and apply actions to block, unblock, delete or email the selected users.

Code

function advuser_user_($type, &$edit, &$account, $category = NULL) {
  static $account_before_edit;
  static $insert = FALSE;
  $return = NULL;
  switch ($type) {
    case 'load':
      if ($insert) {

        // Now the record exists and we can update it.
        if (variable_get('advuser_set_never_access', FALSE)) {
          if ($account->login == 0) {
            $account->access = 0;
            _advuser_update_never_accessed($account->uid);
          }
        }
        $insert = FALSE;
      }

    // continue into the 'form' case.
    case 'form':

      // Need to remove the form identification data!
      // Why does it need to be stored in the data serialized array?!
      $account_before_edit = $account;
      $account_before_edit->form_build_id = '';
      if (isset($account->data) && is_string($account->data)) {
        $account_before_edit->data = unserialize($account->data);
      }
      unset($account_before_edit->data['form_build_id']);
      break;
    case 'insert':

      // Flag that we've seen the insert operation. The insert hasn't occurred
      // but is being readied for insert.
      $insert = TRUE;

      // Notify those that need to be.
      $return = _advuser_receive_notification_by_role('insert', $account);
      break;
    case 'after_update':

      // Need to remove the form identification data!
      // Why does it need to be stored in the data serialized array?!
      $account_after_edit = $account;
      $account_after_edit->form_build_id = '';
      if (is_string($account_after_edit->data)) {
        $account_after_edit->data = unserialize($account->data);
      }
      unset($account_after_edit->data['form_build_id']);
      if ($account_after_edit->login == 0) {
        if (variable_get('advuser_reset_never_access', FALSE)) {
          $account_after_edit->access = 0;
          _advuser_update_never_accessed($account_after_edit->uid);
        }
      }
      if ($account_after_edit != $account_before_edit) {
        $return = _advuser_receive_notification_by_role('update', $account);
      }
      break;
  }
  return $return;
}