Access callback infinite loop in specific case I need to limit node creation to one item for a specific content_type (photography contest), and to redirect the user to its photography if he already posted one. The snippet below is almost working as expected. 

function mymodule_menu_alter(&amp;$items) {
  $items['node/add/slide']['access callback'] = '_mymodule_limit_slide';
}

function _mymodule_limit_slide () {
  global $user;
  if(user_access("create slide content")) {
    $allowed_limit = variable_get('allowed_limit', 1);
    $slides = db_query("SELECT nid, count(*) ct FROM {node} WHERE type = :type AND uid = :uid", array(':type' =&gt; 'slide' ,':uid' =&gt; $user-&gt;uid))-&gt;fetchAssoc();
    if ($slides['ct'] &lt; $allowed_limit || in_array('administrator', $user-&gt;roles)) {
      return TRUE;
    }
    else {
      drupal_set_message('You cannot post more than one photography. But you can edit the one you posted below if yo wish to.');
      drupal_goto(drupal_get_path_alias('node/'.$slides['nid']));
    }
  }
  return FALSE;
}


If I dpm(slides), it returns the correct array and data. 

But, as far as I could debug, if I try to connect a user who :


already posted at least one node of other content type
whether he posted or not a slide


Drupal tries to go to node/'.$slides['nid'] and that creates an infinite loop.

Summary : I don't understand why my function _mymodule_limit_slide () would be called out of node/add/slide url, or what else is wrong ?
I think if you add the access login in the form_alter, the user should be redirected properly. IOW something like this: 

function yourmodule_form_alter(&amp;$form, $form_state, $form_id) {  if($form_id == 'CONTENT-TYPE_node_form') {  global $user;
  if(user_access("create slide content")) {
    $allowed_limit = variable_get('allowed_limit', 1);
    $slides = db_query("SELECT nid, count(*) ct FROM {node} WHERE type = :type AND uid = :uid", array(':type' =&gt; 'slide' ,':uid' =&gt; $user-&gt;uid))-&gt;fetchAssoc();
    if ($slides['ct'] &lt; $allowed_limit || in_array('administrator', $user-&gt;roles)) {
      return TRUE;
    }
    else {
      drupal_set_message('You cannot post more than one photography. But you can edit the one you posted below if yo wish to.');
      drupal_goto(drupal_get_path_alias('node/'.$slides['nid']));
    }
  }
}