Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: Video.js (HTML5 Video Player) 10.0.0-alpha1 First alpha version released for module videojs (10.0.0-alpha1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Disable User Deletion

635 sites Security covered Drupal 9–11
View on drupal.org

This module provides control over user deletion to prevent accidental data loss or ownership issues. It allows administrators to disable options for deleting a user's content or reassigning it to the anonymous user, thereby safeguarding sensitive production data.

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.'));
      }
        }
}

Depends on

Dependencies of the latest stable release

  • user Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Aug 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

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