Hi all, i am trying to change my user register form so that it is a multipage form. The idea is that the admin selects the users role first then on the next page is given some custom fields based on the role selection as well as the standard user register fields. The first page displays fine, However, whenever i click on the next button after the first page it goes to admin/user/user/create but the form shown is the list user page from the admin/user/user page!? It is very strange, the page title is the title for the user/create page, but the rest of the page looks like the admin/user/user page ie with the list user form with the filtering options. I thought it might be a problem with the submit function overriding the #redirect = false or with validate not having enough values to create a user but it doesnt even seem to get to the 'validate' or 'submit' hooks within hook_user. I can tell this because calling print_r($edit); exit(); within either of these cases does nothing. tell me if i am wrong but even if ($step) was not getting passed through the form should surely just show the first page AGAIN rather than redirecting to the list user page?

If anyone knows where i am going wrong, if i need to add something to hook_user instead of hook_form_alter instead or even if anyone has altered an existing drupal form to become multipage form, without writing a whole separate form module. Here is my code for the hook_form_alter, grateful for any help

function mymodule_form_alter($form_id, &$form) {
    if($form_id == 'user_register') {
	  $step = isset($form['_account']['#value']->step) ? (int) $form['_account']['#value']->step : 1;
	  
	  $form['account']['step'] = array(
	    '#type' => 'hidden',
	    '#value' => $step + 1
	  );
	  
	  $form['account']['indicator'] = array(
		'#prefix' => '<div>',
		'#value' => t('Step @number of 2', array('@number' => $step)),
		'#suffix' => '</div>',
		'#weight' => -2
	  );
	  
	  $button_name = t('Submit');
	  if($step < 2) {
		$button_name = t('Next');
	  }
	  $form['submit'] = array(
	    '#type' => 'submit',
		'#value' => $button_name,
		'#weight' => 2
	  );
		
	  switch($step) {
	    case 1: {
                  //Unset form fields we do not want to present at this stage
		  unset($form['name'],$form['mail'],$form['pass'],$form['status'],$form['roles'],$form['notify']);
		  
                 $roles = user_roles(true);
                 //Add my custom fields for step 1
                 $form['myfield1'] = array(
                    '#title' => 'Role',
                    '#type' => 'radios',
                    '#value' => $roles
                 );
		  
		  break;
            }
            case 2: {
               //Add my custom fields for step 2
                 $form['myfield2'] = array(
                    '#title' => 'my second field',
                    '#type' => 'textfield'
                 );

                //Add field from previous step as hidden field
                $form['myHiddenField'] = array(
                    '#value' => $form['_account']['#value']->myfield1,
                    '#type' => 'hidden'
                 );
		  
	       break;
	   }
       }
    
      $form['#multistep'] = TRUE;
      $form['#redirect'] = FALSE;
  }