I wanted to add an option to the "Options" fieldset have have that option saved into the Options column.
I did this by adding another element to the 'optional' fieldset in my hook_user_import_form_fieldsets.
Example:
$form['optional']['force_password_change'] = array(
'#type' => 'checkbox',
'#title' => t('Force password change'),
'#default_value' => empty($import['options']['force_password_change']) ? 0 : $import['options']['force_password_change'],
'#description' => t('Force the user to change their password on first login.'),
);
return $form;
However, I then needed to make some changes to the user_import.inc and user_import.module files to allow the saving to the options column.
In user_import.inc, added '#tree' => TRUE, after line 102.
Result is:
$form['optional'] = array(
'#type' => 'fieldset',
'#title' => t('Options'),
'#tree' => TRUE,
'#weight' => -85,
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
);
Remove or comment out lines 1201-1204. Next, I added the following lines after line 1196 in user_import.module (in the _user_import_settings_save function)
// Settings that have their own column
$columns = array('name', 'pointer', 'processed', 'valid', 'first_line_skip', 'contact', 'username_space', 'send_email', 'field_match', 'roles');
foreach ($settings['optional'] as $option => $value) {
if (!in_array($option, $columns)) {
// This will capture any options that are added to the "optional (Options)" fieldset via
// the hook_user_import_form_fieldsets. It will also capture the 'activate' setting as well.
$settings['options'][$option] = $value;
}
else {
// This will capture options that have their own columns
$settings[$option] = $value;
}
}
// We're done with the 'optional' array, so let's clean up
unset($settings['optional']);
I have attached a patch for the two files.
| Comment | File | Size | Author |
|---|---|---|---|
| Support-for-additional-options.patch | 2.77 KB | dppeak |
Comments
Comment #1
gisleDrupal 6 is no longer supported.
Drupal 6 feature requests are being closed as outdated unless it is obvious that they still apply to the latest stable version.