You are here

function user_delete_cancel_methods in User Delete 6.2

Helper function to return available account cancellation methods.

Backport of D7 version of user_cancel_methods

Return value

An array containing all account cancellation methods as form elements.

See also

hook_user_cancel_methods_alter()

user_admin_settings()

user_cancel_confirm_form()

user_multiple_cancel_confirm()

2 calls to user_delete_cancel_methods()
user_delete_form_alter in ./user_delete.module
Implementation of hook_form_alter().
user_delete_settings in ./user_delete.admin.inc
Administrative settings page

File

./user_delete.module, line 448
Provide account cancellation methods and API to provide the same functionalty as Drupal 7 for cancelling accounts.

Code

function user_delete_cancel_methods() {
  $methods = array(
    'user_cancel_block' => array(
      'title' => t('Disable the account and keep all content.'),
      'description' => t('Your account will be blocked and you will no longer be able to log in. All of your content will remain attributed to your user name.'),
    ),
    'user_cancel_block_unpublish' => array(
      'title' => t('Disable the account and unpublish all content.'),
      'description' => t('Your account will be blocked and you will no longer be able to log in. All of your content will be hidden from everyone but administrators.'),
    ),
    'user_cancel_reassign' => array(
      'title' => t('Delete the account and make all content belong to the %anonymous-name user.', array(
        '%anonymous-name' => variable_get('anonymous', t('Anonymous')),
      )),
      'description' => t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array(
        '%anonymous-name' => variable_get('anonymous', t('Anonymous')),
      )),
    ),
    'user_cancel_delete' => array(
      'title' => t('Delete the account and all content.'),
      'description' => t('Your account will be removed and all account information deleted. All of your content will also be deleted.'),
      'access' => user_access('administer users'),
    ),
  );

  // Allow modules to customize account cancellation methods.
  drupal_alter('user_cancel_methods', $methods);

  // Turn all methods into real form elements.
  $default_method = variable_get('user_cancel_method', 'user_cancel_block');
  foreach ($methods as $name => $method) {
    $form[$name] = array(
      '#type' => 'radio',
      '#title' => $method['title'],
      '#description' => isset($method['description']) ? $method['description'] : NULL,
      '#return_value' => $name,
      '#default_value' => $default_method,
      '#parents' => array(
        'user_cancel_method',
      ),
    );
  }
  return $form;
}