How to rearrange user register form and still pass validation I've implemented a hook_form_alter to change order of fields on user registration form. i've moved mail and username fields inside a fieldset. on submit, drupal is returning an error of undefined mail and account index.
How should i handle this? do i create a submit function that defines $form['mail'] = $form['fieldset']['mail']?
Here's my code:
/**
 * Change the elements from registration form
 *
 * @return outputted form
 * @author 
 **/

function userreg_form_alter(&amp;$form, &amp;$form_state, $form_id){
    if ($form_id == 'user_register_form'){

        if (current_path() == 'supplier/register'){
            unset($form['profile_main']);

            //move the whole form inside suppliers tab
            $supinfo = $form['account'];
            unset($form['account']);

            $form['profile_supplier']['account'] = $supinfo;

            //add our custom form_validate form to handle what we just changed?

            array_unshift($form['#submit'], 'userreg_form_submit');

        }
    }
}

function userreg_form_submit($form_id, &amp;$form_state){

    $form_state['values']['mail'] = $form_state['profile_supplier']['mail'];

}

The error i'm getting is:

Notice: Undefined index: mail in user_account_form_validate() (line
1264 of /var/www/funa/d/modules/user/user.module).
Notice: Undefined index: account in user_account_form_validate() (line 1265 of /var/www/funa/d/modules/user/user.module).
Recoverable fatal error: Argument 2 passed to drupal_array_set_nested_value() must be of the type array, null given,
called in /var/www/funa/d/includes/form.inc on line 2602 and defined
in drupal_array_set_nested_value() (line 6695 of
/var/www/funa/d/includes/common.inc).
I would try defining the name of the field manually like so. This should overwrite the default naming of the variable in the values/input array in the $form_state. 

$form['profile_supplier']['account']['#name'] = 'account';