Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

disable_user_deletion

520 sites Security covered
View on drupal.org

User deletion is always a sensitive task for two key reasons:

  • It can involve the deletion of content or changes to the content's authorization.
  • There are two open core issues: potential content regressions (Issue 3089747) or errors in the ownership of revisions (Issue 2977362).

For these reasons, it is crucial to perform this action in a highly controlled manner.

This module allows you to enable or disable the two actions associated with user deletion:

  • Delete the account and makes its content belong to the Anonymous user.
  • Delete the account and its content.

This helps prevent possible disasters in the production database.

In complex projects, the recommended process is to first test the user deletion in a staging environment. If everything works as expected, you can then proceed with the action in production.

How to configure

  • Go to "/admin/config/disable_user_deletion/settings".
  • Select the actions would you like to disable.

Disable drush commands

To apply these restrictions to Drush commands, copy this code into the file "drush/Commands/PolicyCommands.php":

/**
  * User cancel policy .
  *
  * @hook validate user:cancel
  *
  * @throws \Exception
  */
  public function usercancellValidate(CommandData $commandData) {
    // Only validate if module 'disable_user_deletion' is enabled.
    // @phpstan-ignore-next-line
    if (\Drupal::service('module_handler')->moduleExists('disable_user_deletion')) {
      // @phpstan-ignore-next-line
      $config = \Drupal::config('disable_user_deletion.settings');

      if ($config->get('user_cancel_delete') && $commandData->input()->getOption('delete-content')) {
        throw new \Exception(dt('The option to delete users has been disabled, please contact the technical administrator.'));
      }
      if ($config->get('user_cancel_reassign') && $commandData->input()->getOption('reassign-content')) {
        throw new \Exception(dt('The option to reassign content has been disabled, please contact the technical administrator.'));
      }
        }
}

Activity

Total releases
2
First release
Aug 2025
Latest release
8 months ago
Release cadence
0 days
Stability
50% stable

Releases

Version Type Release date
1.0.1 Stable Aug 18, 2025
1.x-dev Dev Aug 18, 2025