You are here

function uc_extra_fields_pane_user in Extra Fields Checkout Pane 6.2

Implementation of hook_user().

Saves values of extra address fields. Note: the implementation of this function is currently a little bit dirty. It links the extra address fields to the first address from the user it finds. Normally, an user will have only one address after registering, so it assumes this is the case.

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.:

Return value

void

See also

uc_extra_fields_pane_addressfields_user_register_form_alter()

File

./uc_extra_fields_pane.module, line 271
Module: uc_extra_fields_pane.module

Code

function uc_extra_fields_pane_user($op, &$edit, &$account, $category = NULL) {
  global $user;
  if (uc_addresses_version() === 1 && variable_get('uc_addresses_require_address', TRUE)) {
    switch ($op) {
      case 'insert':

        // Load field definitions
        $fields = $fields = UCXF_FieldList::getAllAddressFields();

        // Load address id
        $sQuery = 'SELECT aid FROM {uc_addresses} WHERE uid=%d';
        $address_id = db_result(db_query($sQuery, $edit['uid']));

        // Save values
        foreach ($fields as $fieldname => $field) {
          uc_extra_fields_pane_value_save(array(
            'element_id' => $address_id,
            'element_type' => UCXF_VALUE_ADDRESS,
            'field_id' => $field->field_id,
            'value' => check_plain($edit[$fieldname]),
          ));
        }
        return;
    }
  }
}