If I wanted to create a node programmatically when a module is installed what hook should I use to initiate node_save()? I found guides on how to make the node I just can't seem to figure out how to initiate it.


If it's your own module, use hook_install():

Perform setup tasks when the module is installed.

or hook_enable():

Perform necessary actions after module is enabled.

If it's not your own module, use hook_modules_enabled():

Perform necessary actions after modules are enabled.

This function differs from hook_enable() in that it gives all other modules a chance to perform actions when modules are enabled, whereas hook_enable() is only called on the module actually being enabled. See module_enable() for a detailed description of the order in which install and enable hooks are invoked.

|improve this answer|||||

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.