You are here

function uc_addresses_user_insert in Ubercart Addresses 7

Implements hook_user_insert().

See also

uc_addresses_form_user_register_form_alter()

uc_addresses_form_user_register_form_submit()

File

./uc_addresses.module, line 311
Adds user profile address support to Ubercart.

Code

function uc_addresses_user_insert(&$edit, $account, $category = NULL) {

  // Save the address the user entered during registering.
  if (isset($edit['uc_addresses_address']) && $edit['uc_addresses_address'] instanceof UcAddressesAddress) {
    $address = $edit['uc_addresses_address'];
    $address
      ->setOwner($account->uid);

    // Mark this address as both the default shipping and billing address.
    $address
      ->setAsDefault('shipping');
    $address
      ->setAsDefault('billing');
    $address
      ->save();

    // Unset address from $edit to prevent it from being saved as user data in the user table.
    unset($edit['address']);
    unset($edit['uc_addresses_address']);
  }
  return;
}