Wednesday, December 21, 2011

What is the use of hook_enable?

To show a message after a module gets installed we can use the hook_enable.

For example:

If a module requires a necessary permission to access that module, as soon as the admin installed that module in the drupal admin, we need to show them a message to enable the necessary access permission to access this module at the top.

/**
 * Implementation of hook_enable().
 */
function module_name_enable() {
  drupal_set_message(t('Your module enabled. Don\'t forget to <a href="@link">set permissions</a>.', array('@link' => url('admin/user/permissions', array('fragment' => 'your_custom_module')))));
}




2 comments:

  1. Saved as a favorite, I love your web site!

    ReplyDelete
  2. I think this is among the most significant info for me. And i'm glad reading your article. But wanna remark on some general things, The site style is wonderful, the articles is really excellent : D. Good job, cheers

    ReplyDelete