views:

26

answers:

1

Is there a hook that I can implement in my module so that I can run some clean up code when my module is uninstalled. I create a number of variables using variable_set() and I would like to delete these variables when the module is uninstalled.

+5  A: 

Yes there is.

Where you would write an install hook like this :

/**
 * Implements hook_install().
 */   
function annotate_install(){
    // Use schema API to create database table
    drupal_install_schema('annotate');
}

The uninstall would look like this :

/**
 * Implements hook_uninstall().
 */   
function annotate_uninstall(){
    // Use scheme API to delete database table
    drupal_uninstall_schema('annotate');
    // Delete our module's variable from variables table
    variable_del('annotate_node_types');
}
rlb.usa
Thanks. I guess I wasn't looking in the right place for this hook.
MisterBigs

related questions