Question

I have the following code in a custom module as well as I have firePHP installed (dfb($userId) is supposed to be written in the console). At every page pageload I want to catch and print the current users ID and I think the following should work but it isn't - can anyone tell me why?

function live_update_test_init() {

   global $user;

   $userId = $user->uid;

   dfb($userId);

// Tell drupal that we should watch for new 

if (arg(0) == 'frontpage' && !arg(1)) {

   live_update_initialize('live-update-test');
  }
}
Was it helpful?

Solution

hook_init wont be run on cached pages, that is probably what you are seeing. If you want to run code even on cached pages you should use hook_boot, but be careful not to do something expensive, as it can become a huge performance hit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top