1

This question already has an answer here:

Let's say that there is a contributed module installed in Drupal 7. It alters a SQL statement from the core. Now I have a custom module of my own which alters the same SQL statement in a different way. Now, depending on the alteration, I could have different SQL strings depending on which module hook applies before the other. For example, the first hook deletes a table "field" and the other adds the same table "field". If the first hooks executes earlier, the final SQL has the field added. If it is now the second hook which executes earlier, the extra field is added and later removed, so the SQL is completely different. How can I now the priority, any other conflicting issues and is there a way to override this apparent difficulty?

marked as duplicate by J. Reynolds, Krishna Mohan, Mołot, Clive Feb 9 '15 at 23:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

The system table has a 'weight' field. The hooks are executed in that order.

You can change during install with this code:

function your_module_name_install() {
  db_update('system')
    ->fields(array('weight' => your_preferred_weight))
    ->condition('name', '[your_module_name]', '=')
    ->execute();
}

Source: https://www.drupal.org/node/110238

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