Adding Profile2 fields to user registration I have a custom module that overrides the /user/register page so that in addtion to username and email it also asks for about 10 or so Profile2 pieces of information.

The code I have so far:

    $form['hi'] = array(
      '#type' =&gt; 'fieldset',
      '#prefix' =&gt; '&lt;div id="container_a"&gt;',
      '#suffix' =&gt; '&lt;/div&gt;',
      '#title' =&gt; t('Additional Info'),
    );

    $form['hi']['l'] = array(
      '#type' =&gt; 'fieldset',
      '#prefix' =&gt; '&lt;div id="left"&gt;',
      '#suffix' =&gt; '&lt;/div&gt;',
    );

    $form['hi']['r'] = array(
      '#prefix' =&gt; '&lt;div id="right"&gt;',
      '#suffix' =&gt; '&lt;/div&gt;',
      '#type' =&gt; 'fieldset',

    );

    $form['hi']['l']['h_ph'] = $form['profile_memberlist']['field_home_phone']['und'][0];


The form renders a space for username, email and Home Phone.  I fill out the form, and submit, and I get the following:


  Thank you for applying for an account. Your account is currently pending approval by the site administrator.
  In the meantime, a welcome message with further instructions has been sent to your e-mail >address.


Error message

Notice: Undefined index: profile_memberlist in profile2_form_submit_build_profile() (line 471 of /var/www/html/example/sites/all/modules/profile2/profile2.module).
Warning: array_merge(): Argument #1 is not an array in field_default_extract_form_values() (line 36 of /var/www/html/example/modules/field/field.default.inc).
Recoverable fatal error: Argument 2 passed to drupal_array_get_nested_value() must be an array, null given, called in /var/www/html/example/modules/field/field.default.inc on line 38 and defined in drupal_array_get_nested_value() (line 6608 of /var/www/html/example/includes/common.inc).


I've double checked and the memberlist is the name ( machine name) of the profile2 I am trying to get populated.
I had this in my module:

unset($form['profile_memberlist']);


Which is what I needed to do so I could override and theme the way the form elements were presented.  I commented that out but then I got a dual display of form elements, which I was able to disable with the follwing code:

$form['profile_memberlist'] = array(
      '#type' =&gt; 'hidden',
);