Create a dynamic user registration form using Profiles So, I need to create a user registration form for a website that has numerous types of users that are distinctly different from one another. I've already found the profiles module, and I'm using that. But I want to streamline the user registration process. 

We don't want to create a large form that pushes everyone through the same questions, even if that question isn't applicable to that user. Nor do we want to compromise and only not ask certain questions that are important to that particular type of user. 

I'd also prefer the form to be dynamically updated, rather than a multi-step form.

How can I do this?
Bascially, we create an Ajax callback on the form element used to update the form, and we create an additional form element which is simply a container to display the the relevant profile form. 

I used the Profile 2 Registration Path module to add the Profiles Forms to the User Registration form. I then use hide();  and show(); to display them if appropriate.

The Devel module was also invaluable doing this.

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

        //First, hide all the other profiles
        hide($form['profile_designer']);

        //User selects what type of profile is most appropriate
        $form['profile_main']['field_profile_type']['und']['#ajax'] = array(
            'callback' =&gt; 'rego_update_profile_type',
            'wrapper' =&gt; 'profiles_container',
        );

        //Create a container to the relevant profile
        $form['profiles_container'] = array(
            '#prefix' =&gt; '&lt;div id="profiles_container"&gt;',
            '#suffix' =&gt; '&lt;/div&gt;',
            '#weight' =&gt; '500',
        );
    }
}

//Callback
function rego_update_profile_type($form, $form_state){
    // Switch based on the user input
    switch($form_state['values']['profile_main']...['tid']){
    case '82':
        $form['profiles_container'] = $form['profile_designer'];
        break;
        // --Other cases here --
    }
    //Put back the div id so that the container can be updated again
    $form['profiles_container']['#prefix'] = '&lt;div id="profiles_container"&gt;';
    $form['profiles_container']['#suffix'] = '&lt;/div&gt;';

    show($form['profiles_container']);
    return $form['profiles_container'];
}