You are here

function uc_addresses_user in Ubercart Addresses 6

Same name and namespace in other branches
  1. 5.2 uc_addresses.module \uc_addresses_user()
  2. 5 uc_addresses.module \uc_addresses_user()
  3. 6.2 uc_addresses.module \uc_addresses_user()

Implementation of hook_user().

Parameters

$op An integer representing the action being performed.:

$edit An array of form values submitted by the user.:

$account The user on which the operation is being performed.:

$category The active category of user information being edited.:

File

./uc_addresses.module, line 315

Code

function uc_addresses_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'register':

      // For registration, we may want the user to enter his default
      // address
      if (variable_get('uc_addresses_require_address', TRUE)) {
        $form = uc_addresses_pane_address('new', NULL, $edit);
        $form = array(
          $form['contents'],
        );

        // Modify to what we need
        $form[0]['#title'] = t('Address');

        // Rename the fieldset
        return $form;
      }
      return;
    case 'insert':

      // We're about to add the user to the database, so get the address
      // info and add it to the address table
      $address = (object) $edit;
      $address->is_default = 0;
      _uc_addresses_db_add_address($address);
      return;
    case 'delete':

      // We're deleting the user, so delete all his/her addresses as
      // well
      db_query("DELETE FROM {uc_addresses} WHERE uid = %d", $account->uid);
      db_query("DELETE FROM {uc_addresses_defaults} WHERE uid = %d", $account->uid);
      return;
  }
}