hook_user_cancel_methods_alter(&$methods)
Modify account cancellation methods.
By implementing this hook, modules are able to add, customize, or remove account cancellation methods. All defined methods are turned into radio button form elements by user_cancel_methods() after this hook is invoked. The following properties can be defined for each method:
array $methods: An array containing user account cancellation methods, keyed by method id.
\Drupal\user\Form\UserCancelForm
function hook_user_cancel_methods_alter(&$methods) { $account = \Drupal::currentUser(); // Limit access to disable account and unpublish content method. $methods['user_cancel_block_unpublish']['access'] = $account->hasPermission('administer site configuration'); // Remove the content re-assigning method. unset($methods['user_cancel_reassign']); // Add a custom zero-out method. $methods['mymodule_zero_out'] = array( 'title' => t('Delete the account and remove all content.'), 'description' => t('All your content will be replaced by empty strings.'), // access should be used for administrative methods only. 'access' => $account->hasPermission('access zero-out account cancellation method'), ); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!user!user.api.php/function/hook_user_cancel_methods_alter/8.1.x