0

So I looked at the features API, and in order to enable a feature, they use this code:

function hook_pre_features_enable_feature($component){
};

So I go in and add this:

function mysite_pre_features_enable_feature($component){
    $component = 'roles';
};

My Feature is already there, but it never gets enabled. Why is this?

1

in order to enable a feature, they use this code

That's not accurate. The hook function is actually:

Invoked on a Feature module before that module is enabled.

It's not involved with the action of enabling the feature, it's just a listener to enable it to run some code just before something else enables it.

Features are just modules, and to enable one you use the same method as if you were just enabling a module:

module_enable(['foo']);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.