how do i make diffrent registration form in drupal?

好久不见. 提交于 2019-12-24 06:57:52

问题


Is there a module that can make different registration forms for different roles during sign up? (ex. each Editor,Main User,Sub User role have different form)


回答1:


There is :)

http://drupal.org/project/autoassignrole

to assign by path you will also need Content Profile:

http://drupal.org/project/content_profile

check out this tutorial on how to pull it off:

http://www.web-a-team.com/blog-post/user-registration-more-one-role




回答2:


Here's what you should do

  1. start with install profile2-7.x-1.2.tar.gz.
  2. entity-7.x-1.0-rc3.tar.gz once you have profile2 installed -->
  3. enable --> click on configure - (Here you see your profile types -add as many as you want).

when you add a new one or modify the existing one "Main" make sure you check "Provide a separate page for editing profiles." 4. Now to have different registration, login and password change pages install and enable profile2_regpath-7.x-1.9.tar.gz Now visit the profile Types Page again here you should see "UNIQUE REGISTRATION PATH" .. rest is easy ..




回答3:


Here is some idea how to solve your question in drupal 7(I think it should work in drupal 6 also). However its not safe since anyone can just change the role they have:

function my_module_form_user_register_form_alter(&$form, &$form_state, $form_id) {

    $company_role = $form_state['build_info']['args'][0];

    $form['account']['company_role'] = array(
        '#type'         => 'select',
        '#title'        => t('Company role'),
        '#options'      => drupal_map_assoc(array('editor','main user','Sub User')),
        '#description'  => t('Please select your company role'),
        "#empty_option" =>t('- Select -'),
        '#weight'       => -11,  // Add the select box above username that have weight -10

    );

    switch (strtolower($company_role)) {
        case 'editor':
            // add extra fields for editor
            $form['account']['company_role']['#default_value'] = $company_role;
            break;
        case 'main user':
            // add extra fields for main
            $form['account']['company_role']['#default_value'] = $company_role;
        case 'sub user';
            // add extra fields for 'Sub User'
            $form['account']['company_role']['#default_value'] = $company_role;
            break;
        default:
            $form['account']['company_role']['#empty_option'] = t('- Select -');
            $company_role = null;// error handling or default case
    }

}

If you for example have LDAP in your company you could instead get this information from LDAP(https://www.drupal.org/node/1053748). Then you can be more sure about the role is chosen correctly.



来源:https://stackoverflow.com/questions/4992992/how-do-i-make-diffrent-registration-form-in-drupal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!