I'm trying to get a little more familiar with writing extensions. I am still struggling with finding the correct / most specific hook function for my patches regularly.

As a specific example, I am altering an SQL call in sites/all/modules/civicrm/CRM/Case/BAO/Case.php::getCaseActivity(). So if I want to create an extension for that, I would need a hook function that will be called whenever sth is read from a database table. I checked all the hooks in https://docs.civicrm.org/dev/en/latest/hooks/ but couldn't find a suitable one.

Is there a hook function like that? Is there a more specific alternative to save resources (checking the hook extension each time a database table is called would happen lots of times)?

Can I create custom hook "call points" to determine at which line of code a hook is called?

1 Answer 1


There is no hook for reading data from the database. There are hooks however for rendering forms and pages.

There is also a hook for api v3 which is called before and after each api call. That hook is called apiWrapper

  • As you said there is a hook for reading data from the database - can you tell me which one?
    – emma
    Oct 8, 2020 at 14:19
  • 2
    I believe Jaap dropped a word "no". There isn't a hook for reading data from the database. Such a hook would be near impossible to write, because unlike writing to the database, reading the database can happen in many ways - viewing a contact, doing a search, running a report, etc. Oct 9, 2020 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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