function user_cancel_methods

Helper function to return available account cancellation methods.

See documentation of hook_user_cancel_methods_alter().

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()

3 calls to user_cancel_methods()
user_admin_settings in drupal/core/modules/user/user.admin.inc
Form builder; Configure user settings for this site.
user_cancel_confirm_form in drupal/core/modules/user/user.pages.inc
Form builder; confirm form for cancelling user account.
user_multiple_cancel_confirm in drupal/core/modules/user/user.module

File

drupal/core/modules/user/user.pages.inc, line 334
User page callback file for the user module.

Code

function user_cancel_methods() {
  $anonymous_name = config('user.settings')
    ->get('anonymous');
  $methods = array(
    'user_cancel_block' => array(
      'title' => t('Disable the account and keep its 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 its 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 its content belong to the %anonymous-name user.', array(
        '%anonymous-name' => $anonymous_name,
      )),
      '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' => $anonymous_name,
      )),
    ),
    'user_cancel_delete' => array(
      'title' => t('Delete the account and its 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 = config('user.settings')
    ->get('cancel_method');
  $form = array(
    '#options' => array(),
    '#default_value' => $default_method,
  );
  foreach ($methods as $name => $method) {
    $form['#options'][$name] = $method['title'];

    // Add the description for the confirmation form. This description is never
    // shown for the cancel method option, only on the confirmation form.
    // Therefore, we use a custom #confirm_description property.
    if (isset($method['description'])) {
      $form[$name]['#confirm_description'] = $method['description'];
    }
    if (isset($method['access'])) {
      $form[$name]['#access'] = $method['access'];
    }
  }
  return $form;
}