function user_delete_form_alter in User Delete 6
Same name and namespace in other branches
- 5 user_delete.module \user_delete_form_alter()
- 6.2 user_delete.module \user_delete_form_alter()
Implementation of hook_form_alter().
File
- ./
user_delete.module, line 66 - User delete - Let users delete their own account.
Code
function user_delete_form_alter(&$form, $form_state, $form_id) {
global $user;
if ($form_id == 'user_profile_form') {
//access check
if (user_access('delete own account') && $form['#uid'] == $user->uid && arg(3) == '') {
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete Account'),
'#weight' => 31,
'#submit' => array(
'user_edit_delete_submit',
),
);
}
}
if ($form_id == 'user_confirm_delete') {
$description = '';
$default_op = variable_get('user_delete_default_action', 0);
if ($default_op) {
switch ($default_op) {
case 'user_delete_block':
$description = t('The account will be disabled, all submitted content will be kept.');
break;
case 'user_delete_block_unpublish':
$description = t('The account will be disabled, all submitted content will be unpublished.');
break;
case 'user_delete_reassign':
$description = t('The account will be deleted, all submitted content will be reassigned to the <em>Anonymous user</em>. This action cannot be undone.');
break;
case 'user_delete_delete':
$description = t('The account and all submitted content will be deleted. This action cannot be undone.');
break;
}
$form['description'] = array(
'#value' => $description,
'#weight' => -10,
);
}
if (variable_get('user_delete_backup', 0)) {
$form['user_delete_remark'] = array(
'#value' => t('All data that is being deleted will be backed up for %period and automatically deleted afterwards.', array(
'%period' => format_interval(variable_get('user_delete_backup_period', 60 * 60 * 24 * 7 * 12), 2),
)),
'#weight' => -10,
);
}
if (!variable_get('user_delete_default_action', 0)) {
$form['user_delete_action'] = array(
'#type' => 'radios',
'#title' => t('When deleting the account'),
'#default_value' => 'user_delete_block',
'#options' => array(
'user_delete_block' => t('Disable the account and keep all content.'),
'user_delete_block_unpublish' => t('Disable the account and unpublish all content.'),
'user_delete_reassign' => t('Delete the account and make all content belong to the <em>Anonymous user</em>.'),
'user_delete_delete' => t('Delete the account and all content.'),
),
'#weight' => 0,
);
}
$form['#redirect'] = 'user/' . $form['_account']['#value']->uid;
$form['#submit'] = array(
'user_delete_submit',
);
}
}