Override default register form &lt;?php
/*
** Implements hook_menu().
*/
function custom_register_menu() {
    $items = array();
    $items['custom-register'] = array(
    'title' =&gt; 'Custom register',
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('custom_register_form'),
    'access arguments' =&gt; array('access content'),
  );
    return $items;
}
/*
** Implements hook_form().
*/
function custom_register_form($form, &amp;$form_state) {
  // Display page 2 if $form_state['page_num'] == 2
  if (!empty($form_state['page_num']) &amp;&amp; $form_state['page_num'] == 2) {
    return custom_register_page_two($form, $form_state);
  }
  // Otherwise we build page 1.
  $form_state['page_num'] = 1;
  $form['egn'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('EGN'),
    '#size' =&gt; 20,
    '#maxlength' =&gt; 10,
    '#required' =&gt; TRUE,
  );
  $form['last_digits'] = array(
    '#type' =&gt; 'textfield',
    '#size' =&gt; 20,
    '#maxlength' =&gt; 4,
    '#title' =&gt; t('Last digits from the card '),
    '#required' =&gt; TRUE,
  );
  $form['authorization_code'] = array(
       '#type' =&gt; 'textfield',
     '#size' =&gt; 20,
     '#maxlength' =&gt; 6,
     '#title' =&gt; t('Authorization code'),
     '#required' =&gt; TRUE,
  );
  $form['transcation_date'] = array(
       '#type' =&gt; 'textfield',
     '#size' =&gt; 20,
     '#title' =&gt; t('Transaction date'),
     '#required' =&gt; TRUE,
  );
  $form['next'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Forward&gt;'),
    '#submit' =&gt; array('custom_register_next_submit'),
    '#validate' =&gt; array('custom_register_next_validate'),
  );
  //dsm($form_state);
  return $form;
}
/**
* Validate handler for the next button on first page.
*/
function custom_register_next_validate($form, &amp;$form_state) {
    if(!is_numeric($form_state['values']['egn'])) {
        form_set_error('egn', t('Please enter only numbers!'));
    }
    $egn_length = strlen($form_state['values']['egn']);
    if($egn_length == 10) {
    }  else {
        form_set_error('egn', t('Please insert proper ЕГН'));
    }
    if(!is_numeric($form_state['values']['last_digits'])) {
        form_set_error('last_digits', t('Please enter only digits!'));
    }
    $last_digits_length = strlen($form_state['values']['last_digits']);
    if($last_digits_length == 4) {
    }  else {
        form_set_error('last_digits', t('Please enter 4 digits!'));
    }
    $authorization_code_length = strlen($form_state['values']['authorization_code']);
    if($authorization_code_length == 6) {
    }  else {
        form_set_error('authorization_code', t('Please enter 6 digits!'));
    }


I'm building a multistep form for custom registration on Drupal 7.
The reason that I don't use hook_form_alter is because later I have to create a submit handler to a webservice and other database, but I'll open a new thread later for that.

This is a part of my code (sorry about putting text the down bellow, but drupal.stackexhange is not so friendly for putting text and codes) and you can see that I've created a menu page (custom-register).
On that page there are four fields with custom validators and next button. On the next step it should be displayed the Drupal four fields (username, password, password repeat and email) and after that it should redirect to some register successful message page.

My questions are:


How can I redirect /custom-register to user/register page? I've read about hook_form_alter, but I didn't find a way how to override user/register page.
For the second step of the form after submitting how can I create a new user like on the core user module?


EDIT:

I've managed to alter the default register form with my new form created. :) This is the code:

&lt;?php

    function custom_register_menu_alter(&amp;$items) {
        $items['user/register']['page arguments'] = array('custom_register_form'); 
        return $items;  

    }


Now the next thing is to create the 4 fields (username, password, password repeat and email) and to find a right submit handler to save the user.
You can still use hook_form_alter and have a special variable (in the $_SESSION for example) to define which part of the form do you need to show. Code sample below:

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) 
{
  if ($form_id === 'user_register_form') {
     switch ($_SESSION['register_step']) {
         case 1:
              // confirm smth
         break;
         case 2:
              // establish the connections to other services, etc.
         break;
         default:
              // show initial form
         break;
     }
  }
}


Hope this is helpful.

EDIT

Some links:


Creating a user programmatically
Custom submit
handlers