hook to redirect user before they create node? I'm running a db_query to check if the user has taken a specific action. If they haven't, I'm redirecting them to the page where they can take that action.

function my_special_module_node_view(...) {
   db_query(...);

   if( $fails ) { 
     drupal_set_message(t('Error'), 'error');
     drupal_goto('new_page');
   }
}


hook_node_view is mostly working right. It redirects from most pages except any user account pages. The only problem is it doesn't catch when they are trying to create a node. What hook can I use to redirect the user before they view the node creation form?

Update

I've switched it to hook_page_alter. This catches all URLs including the node creation form, which is progress. I had to add in some logic to skip certain paths (including the new_page path to avoid an infinite loop). It seems to be working much better, except if the user does not have access to a page it still ends up in an infinite loop. My current code:

function my_special_module_page_alter() {
  db_query(...);

  if( $fails ) {
    $base_path = arg(0);
    if( !in_array($base_path, array('new_page', 'user')) ) {
      drupal_set_message(t('Error'), 'error');
      drupal_goto('new_page');
    }
  }
}


Any ideas why the pages the user does not have access to end up in a redirect loop? Is there a simple function I can call within hook_page_alter that checks "if user_has_access_to_this_page"?
If I am understanding this correctly, this might be a job for hook_init(), eg something along these lines:

function YOURMODULE_init() {
  global $user;

  if ($user-&gt;uid) {

    $fails = /* whatever */ ;

    if ($_GET['q']!='node/add/foo') {

      if ($fails) {
        drupal_set_message('How about creating foo first...');
        drupal_goto('node/add/foo');
      }

    }

  }

}