You are here

function profile_save_profile in Drupal 4

Same name and namespace in other branches
  1. 5 modules/profile/profile.module \profile_save_profile()
  2. 6 modules/profile/profile.module \profile_save_profile()
  3. 7 modules/profile/profile.module \profile_save_profile()
1 call to profile_save_profile()
profile_user in modules/profile.module
Implementation of hook_user().

File

modules/profile.module, line 502
Support for configurable user profiles.

Code

function profile_save_profile(&$edit, &$user, $category) {
  if (arg(0) == 'user' && arg(1) == 'register' || arg(0) == 'admin' && arg(1) == 'user' && arg(2) == 'create') {
    $result = db_query('SELECT fid, name, type FROM {profile_fields} WHERE register = 1 AND visibility != %d ORDER BY category, weight', PROFILE_HIDDEN);
  }
  else {
    $result = db_query("SELECT fid, name, type FROM {profile_fields} WHERE LOWER(category) = LOWER('%s') AND visibility != %d", $category, PROFILE_HIDDEN);

    // Use LOWER('%s') instead of PHP's strtolower() to avoid UTF-8 conversion issues.
  }
  while ($field = db_fetch_object($result)) {
    if (_profile_field_serialize($field->type)) {
      $edit[$field->name] = serialize($edit[$field->name]);
    }
    db_query("DELETE FROM {profile_values} WHERE fid = %d AND uid = %d", $field->fid, $user->uid);
    db_query("INSERT INTO {profile_values} (fid, uid, value) VALUES (%d, %d, '%s')", $field->fid, $user->uid, $edit[$field->name]);

    // Mark field as handled (prevents saving to user->data).
    $edit[$field->name] = NULL;
  }
}