User registration question I have built a new form from scratch. I was examining a code example displayed on here earlier, but I am not sure if I fully understand the syntax. 

So far I have the following code:

$items['user/register'] = array(
    'title' =&gt; 'a large ferrret', 
    'page callback' =&gt; 'redirect_custom_reg_form', 
    'page arguments' =&gt; array('user_register_form'), 
    'access callback' =&gt; TRUE, 
    'type' =&gt; MENU_LOCAL_TASK,
);


I looked at a similar example in my book, and it looks like the page callback is used to build the form. I have  used a similar example which uses the page callback. 

Could someone please explain this function to me. I understand that this is a menu alter function. this should check to see if the user/register page is set

function redirect_custom_reg_form__menu_alter(&amp;$items) {
  if (isset($items['user/register'])) {
    $items['user/register']['page arguments'] = array('mymodule_user_register_form');
  }
}



function mymodule_user_register_form($form) {
 $fields['legal_agreement'] = array (
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('Legal Agreement')
 );

 $fields['legal_agreement']['PL'] = array (
    '#type' =&gt; 'checkbox',
    '#title' =&gt; t('Legal Agreement')
 );     


 $fields['legal_agreement']['decision'] = array(
    '#type' =&gt; 'radios',
    '#description' =&gt; t('By registering at %site-name, I certify that I am over 18 and have read and accepted the terms and conditions of the pravacy policy', array('%site-name' =&gt; variable_get('site_name', 'drupal'))),
    '#default_value' =&gt; 0,
    '#options' =&gt; array(t('I disagree'), t('I agree'))
 );

 return $fields;
}


I then made the assumption that I need a page callback method and this callback builds my page. It does not seem to be rebuilding anything.
In Drupal 6, you implement hook_user() to add the extra fields to the registration form implemented by Drupal.

function mymodule_user($op, &amp;$edit, &amp;$account, $category = NULL) {
  if ($op == 'register' &amp;&amp; $category == 'account') {
    $form['legal_agreement'] = array (
      '#type' =&gt; 'fieldset',
      '#title' =&gt; t('Legal Agreement')
    );

    $form['legal_agreement']['decision'] = array(
      '#type' =&gt; 'radios',
      '#description' =&gt; t('By registering at %site-name, I certify that I am over 18, and I have read and accepted the terms and conditions of the privacy policy.', array('%site-name' =&gt; variable_get('site_name', 'drupal'))),
      '#default_value' =&gt; 0,
      '#options' =&gt; array(t('I disagree'), t('I agree'))
    );

    return $form;
  }

  if ($type == 'validate' &amp;&amp; $category == 'account') {
    // If the user needs to always agree with the conditions, this is the place to show an error message.
  } 
}


If you want to completely replace the registration form used by Drupal with your own, then you need to implement hook_menu_alter().

function mymodule_menu_alter(&amp;$items) {
  if (isset($items['user/register'])) {
    $items['user/register']['page arguments'] = array('mymodule_user_register_form');
  }
}

function mymodule_user_register_form() {
  $form = array();

  // Add the form fields for the registration form.

  return $form;
}


&nbsp; 

In Drupal 7, as you are just adding form fields to an existing form, you need to implement hook_form_FORM_ID_alter() using code similar to the following one:

function mymodule_form_user_register_form_alter(&amp;$form, &amp;$form_state) {
  $form['legal_agreement'] = array (
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('Legal Agreement')
  );

  $form['legal_agreement']['decision'] = array(
    '#type' =&gt; 'radios',
    '#description' =&gt; t('By registering at %site-name, I certify that I am over 18, and I have read and accepted the terms and conditions of the privacy policy.', array('%site-name' =&gt; variable_get('site_name', 'drupal'))),
    '#default_value' =&gt; 0,
    '#options' =&gt; array(t('I disagree'), t('I agree'))
  );
}


The variable that contains the form definition is $form, and the hook doesn't need to return any value, as the form that needs to be modified is passed by reference.

This is very similar to the example code reported in the documentation page for hook_form_FORM_ID_alter(), which uses the following code:

  // Modification for the form with the given form ID goes here. For example, if
  // FORM_ID is "user_register_form" this code would run only on the user
  // registration form.

  // Add a checkbox to registration form about agreeing to terms of use.
  $form['terms_of_use'] = array(
    '#type' =&gt; 'checkbox', 
    '#title' =&gt; t("I agree with the website's terms and conditions."), 
    '#required' =&gt; TRUE,
  );


&nbsp; 

If you want to completely replace the registration form used by Drupal with your own, then you need to implement hook_menu_alter().

function mymodule_menu_alter(&amp;$items) {
  if (isset($items['user/register'])) {
    $items['user/register']['page arguments'] = array('mymodule_user_register_form');
  }
}

function mymodule_user_register_form($form, &amp;$form_state) {
  // Add the form fields for the registration form; the variable containing it is $form.

  return $form;
}


To notice that in the Drupal code, the form builder receives $form as argument. The common error when porting code from Drupal 6 to Drupal 7 is to still have $form = array() at the beginning of the form builder function.
In both the cases, when you implement hook_menu_alter(), your module needs to handle all the registration process.