Uninstall Drupal Module In Code

Last modified: 
Sunday, March 29th, 2015

This is an example of how to uninstall in a Drupal 7 module in code. You would normally do this in hook_update_N in ''mymodule.install'.

/**
 * This line will appear in drush updb prompts. 
 */
function mymodule_update_7101() {
  // Uninstall the Backup & Migrate module.
  $modules = array(
      'backup_migrate',
  );
  // drupal_uninstall_modules() will skip over modules 
  // that are still enabled, so be sure to disable them yourself. 
  module_disable($modules);
  drupal_uninstall_modules($modules);
}

References


The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.