function user_edit_user_attributes_form_submit

7.x user.module user_edit_user_attributes_form_submit($form, $form_state)
6.x user.module user_edit_user_attributes_form_submit($form, $form_state)

File

modules/user/user.module, line 513

Code

function user_edit_user_attributes_form_submit($form, $form_state) {

  $values = $form_state ['values'];
  $user_id = intval($values ['user_id']);

  $attributes = user_get_registered_attributes();
  foreach ($attributes as $name => $definition) {

    if (!isset($attributes [$name]['fields'])) {
      // Create a "default" field of "value" that's a simple textfield.
      $attributes [$name]['fields']['value'] = array(
        'label' => $attributes [$name]['title'],
        'type' => 'textfield',
      );
    }

    foreach ($attributes [$name]['fields'] as $attr_key => $details) {

      $fieldname = $name . "__" . $attr_key;
      if (user_has_permission("edit_attribute_" . $name)) {
        $val = @trim($values [$fieldname]);
        user_set_attribute($user_id, $fieldname, $val);
      }

    }
  }

  fp_add_message(t("User attributes have been updated successfully."));


}