Set Drupal Module Weight

markdorison picture markdorison · Jan 12, 2011 · Viewed 10.3k times · Source

When developing a custom module, what is the correct way to set a module's weight?

Answer

jackocnr picture jackocnr · Aug 20, 2012

This is the correct way to do it in Drupal 7

/**
 * Implements hook_enable()
 */
function YOUR_MODULE_enable() {
    db_update('system')
    ->fields(array('weight' => 1))
    ->condition('type', 'module')
    ->condition('name', 'YOUR_MODULE')
    ->execute();
}