views:

27

answers:

1

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');
  }
}
+2  A: 

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.

googletorp
Alrigt thanks a lot!I just wanted to be sure that it's getting the userId so I wont be using the hook_boot()
Martin