How to revert a Features module programmatically

This is how you can revert a Features module in Drupal 6 programmatically in for instance a install file or elsewhere.

//If used in a install file you need to include the Features module functions

$feature = features_get_features('my_feature_module_name');
$components = array_keys($feature->info['features']);
features_revert(array('my_feature_module_name' => $components));



//In your module you can also create a function like this
function mymodule_features_revert_module($module) {
$feature = features_get_features($module);
$components = array_keys($feature->info['features']);
features_revert(array($module => $components));

//...and call it like this

Knowledge keywords: