Day 21 - Replacing hook_init / Doing something on every page

General Instructions for any Exercise Card

  • Pick the Activity Card you wish to work on, and Download the PDF card
  • Spend some time reading through or watching the Primary Tutorial
  • Implement the exercise
  • Use Hints/Debug/Solution/Additional Resources provided on some of the cards
  • Discuss in comments should you have any queries


  • Although doing stuff in hook_init is avoided as there is always a better way of doing the same thing elsewhere. We have taken a look at the event subscriber system on Day-18. We will be extending the same to hook into the page response to do something before every response is rendered, just as you did with hook_init()!
Activity Card Download