2 * Implements hook_user_cancel_methods_alter().
4 function {{ machine_name }}_user_cancel_methods_alter(&$methods) {
5 $account = \Drupal::currentUser();
6 // Limit access to disable account and unpublish content method.
7 $methods['user_cancel_block_unpublish']['access'] = $account->hasPermission('administer site configuration');
9 // Remove the content re-assigning method.
10 unset($methods['user_cancel_reassign']);
12 // Add a custom zero-out method.
13 $methods['mymodule_zero_out'] = [
14 'title' => t('Delete the account and remove all content.'),
15 'description' => t('All your content will be replaced by empty strings.'),
16 // access should be used for administrative methods only.
17 'access' => $account->hasPermission('access zero-out account cancellation method'),