I am using hook_init to check if a variable is set, and then redirect if not...

function quickstart_init() {
  if (variable_get('quickstart_admin', 0) != 1 && $_SERVER['REQUEST_URI'] != '/welcome/admin') {

This works for logged out users, but when you are logged in, it redirects - but the whole page displays twice!

I have traced this down to admin menu, as the second version of the page only appears once that JS runs. Does anyone know if admin_menu bootstraps onload? In which case, probably run hook_init again?

Anyway, main question....

What can i do to only run this once, is there something other than hook init that would work?

1 Answer 1


You should really try to get to the bottom of why hook_init is being called twice, but for a band-aid solution, you can use a static variable (using drupal_static) to keep track of whether your implementation of hook_init has already been called.

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.