User registration form at a new menu path got error after submit I'm creating an employee directory. I created a menu path which renders user registration form with profile fields.
When I submit the form, I got some unknown errors. I did fill out every fields in the form, but drupal shows "required" errors.


  Error
  The website encountered an unexpected error. Please try again later.
  
  
  Password field is required.
  You must enter a username.
  You must enter an e-mail address.
  Notice: Undefined index: array_parents in field_default_form_errors() (line 369 of
  D:\fakepath\testsite\modules\field\field.form.inc).
  Recoverable fatal error: Argument 2 passed to drupal_array_get_nested_value() must be an array, null given, called
  in D:\fakepath\testsite\modules\field\field.form.inc on line 369 and
  defined in drupal_array_get_nested_value() (line 6490 of
  D:\fakepath\testsite\includes\common.inc).
  


I have hook_form_alter in which some fields are made hidden.
Here is my code snippet in my custom module.

&lt;?php
/*
 * Implementation of hook_menu()
 */
function mymodule_menu(){
    $items['employee/create'] = array(
        'title' =&gt; t('Create Directory'),
        'page callback' =&gt; 'drupal_get_form',
        'access callback' =&gt; 'mymodule_access_directory',
        'page arguments' =&gt; array('mymodule_employee_create_form'),
        'type' =&gt; MENU_NORMAL_ITEM,
        'weight' =&gt; 0,
    );
    return $items;
}
/*
 * Implementation of access callback for the menu
 */
function mymodule_access_directory(){
    global $user;
    # administrator can only access this
    if( in_array('administrator', $user-&gt;roles) ){ 
        return TRUE;
    }
    return FALSE;
}
/**
 * Home page which shows latest entered ten legs with cheapest tickets
 */
function mymodule_employee_create_form(){
    drupal_set_title('Create Employee Directory');
    return drupal_get_form('user_register_form');
}

/**
 * Implementation of hook_form_alter
 * Override form structure
*/
function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {

    if($form_id == 'user_register_form'){       
        if($_GET['q'] == 'employee/create'){ # admin only can access this page
            # hide drupal default role selection; default role is employee
            $form['account']['roles']['#default_value'] = array(6);
            _mymodule_hide_elem($form, 'roles', 'account');
            # hide auto assign role selection; default role is employee
            $form['autoassignrole_user']['user_roles']['#default_value'] = 6;
            _mymodule_hide_elem($form, 'autoassignrole_user');
            # hide Status
            _mymodule_hide_elem($form, 'status', 'account');
            # hide Notify
            _mymodule_hide_elem($form, 'notify', 'account');

            # Change "Create new account" to "Create"
            $form['actions']['submit']['#value'] = 'Create';
        }


    }
}   

function _mymodule_hide_elem(&amp;$form, $name, $group=NULL){
    if($group){
        $form[$group][$name]['#prefix']     = '&lt;div style="display:none"&gt;';
        $form[$group][$name]['#suffix']     = '&lt;/div&gt;'; 
        $form[$group][$name]['#required']   = FALSE;        
    }else{
        $form[$name]['#prefix']     = '&lt;div style="display:none"&gt;';
        $form[$name]['#suffix']     = '&lt;/div&gt;'; 
        $form[$name]['#required']   = FALSE;
    }
}
?&gt;
My mistake in my hook_menu(). The page arguments should be array('user_registration_form') and I removed the custom page callback mymodule_employee_create_form(). It did work as expected.

function mymodule_menu(){
    $items['employee/create'] = array(
        'title' =&gt; t('Create Directory'),
        'page callback' =&gt; 'drupal_get_form',
        'page arguments' =&gt; array('user_register_form'),        
        'access callback' =&gt; 'mymodule_access_directory',
        'type' =&gt; MENU_NORMAL_ITEM,
        'weight' =&gt; 0,
    );
    return $items;
}