Anonymous user form submission I have a situation where after doing the basic registration the user is redirected to a page where he needs to fill a small form.

I aim at implementing the hook_user_insert() and hook_menu() to do something like this

function registration_user_insert(&amp;$edit, $account, $category){
  drupal_goto('splan/'.$edit['uid']);
}

function registration_menu() {
  $items['splan/%'] = array(
    'title' =&gt; 'Select a Plan',
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('selectplan_form'),
    'access callback' =&gt; TRUE,
    'type' =&gt; MENU_CALLBACK
  );

  return $items;
}


In selectplan_form() I will define my new form and then, using the user ID, I would save data into user table.

The basic user registration form is being submitted, the user is redirected to splan/uid, but I also get the following error.


  You are not authorized to access this page.


I have changed permissions to allow anonymous users to create and edit webform, but the problem still persists.
Implementing hook_user_insert() this way (calling drupal_goto() inside) is plain wrong:


if there are any other implementations of this hook in other modules meant to be called after yours, they will not get called at all
if for whatever reason hook_user_insert() from user module will not be called before your implementation, the user will not be saved at all
if you look at user_save() function in user.module, you'll see that after invoking 'insert' hook there are many other things this function is doing, so if you use drupal_goto(), they will not be done.


What you can do though is to add your own submit function to user_register_form, and in that function set $form_state['redirect'] to wherever you want (note that updating $form_state['redirect'] in hook_form_alter() will not work in this case, as user_register_submit() sets its own redirect, so you need to do it after this - hence the need for your own submit).