A module often has some one-time setup initialization to do, some of which can be easily automated (e.g., set a system variable), some of which may require site admin input. But there's no available method to detect and act on module enabling.

So the attached patch implements one possible approach: a new _enable() hook, that would be called when a module is enabled.

I suppose an alternate approach would be simply to redirect to the module's setting's page, if available; but, because multiple modules can be enabled at the same time, that might be impractical.

I know, three days before code freeze is not the best time to be bringing up new proposed hooks! I'll be happy to wait until next cycle to work the idea through.

CommentFileSizeAuthor
module_enable_hook.patch1.05 KBnedjo

Comments

drumm’s picture

You don't need to add yet another query for this. The list of previously enabled modules is availiable from module_list() and the list of now enabled modules is in $edit.

drumm’s picture

Component: module system » other
Status: Needs review » Closed (duplicate)