1

I want to have 2 customised registration/sign-up form for different users with different fields for their account and profile (like buyer and supplier). How to make different form or multi step form for each kind of user based on role.

How can it be accomplish? Please help in this regard. As after lot of search, i could not figure it out. Is there better approach which is being used then please let me know.

3 Answers 3

2

When you need different set of fields for different users you should have a look at the profiles 2 module. There's a good chance that you can acomplish your requirements without any coding.

BTW: This kind of question has been asked many times here. The search functionality will give you a lot of information about this topic.

0
2

I have found an answer by using the module Profile2 Registration Path.

This module enables administrators to set unique registration paths per Profile2 profile type.

Overview

The Problem

By default, the Profile 2 module permits you to add fields from chosen profile types to the default user registration form. Unfortunately, there is only one user registration form. Thus, every user will be presented with these fields during registration. If you have two profile types targeted at two different audiences, you cannot have two separate registration forms.

The Solution

Profile2 Registration Path enables you to set a unique registration path for each Profile2 profile type. Users who register via that unique path will be presented with fields from the chosen profile type(s).

1

You need to use a hook or theming the form. See Customizing the login form.

Step 1 of 2

In a text editor like notepad.exe, create a file called template.php using the the following snippet. If you already have a template.php file, simply add it to your existing one.

Form variables are declared as render elements in hook_theme functions that handle form or element theming. See the hook_theme API documentation for more information.

function mytheme_theme(&$existing, $type, $theme, $path) {
  $hooks['user_login'] = array(
    'template' => 'templates/user_login',
    'render element' => 'form',
    // other theme registration code...
  );
  return $hooks;
}

function mytheme_preprocess_user_login(&$variables) {
  $variables['intro_text'] = t('This is my awesome login form');
  $variables['rendered'] = drupal_render_children($variables['form']);
}

Step 2 of 2

  • In a text editor paste the following snippet into your user_login.tpl.php file
  • Edit the style sheet classes and content to suit
  • Upload your edited user_login.tpl.php to your active theme folder

    <p><?php print $intro_text; ?></p>
    <div class="my-form-wrapper">
      <?php print $rendered; ?>
    </div>
    

Style sheet reference

For controlling how your login form looks using your style sheet, this is what the rendered login form HTML and class names are by default:

<div class="form-item">
 <label for="edit-name">Username: <span class="form-required" title="This field is required.">*</span></label>
 <input type="text" maxlength="60" name="name" id="edit-name"  size="30" value="" tabindex="1" class="form-text required" />
 <div class="description">enter your username</div>
</div>
<div class="form-item">
 <label for="edit-pass">Password: <span class="form-required" title="This field is required.">*</span></label>
 <input type="password" name="pass" id="edit-pass"  size="40"  tabindex="2" class="form-text required" />
 <div class="description">enter your password</div>
</div>
<input type="hidden" name="form_id" id="edit-user-login" value="user_login"  />
<input type="submit" name="op" id="edit-submit" value="Log in"  tabindex="3" class="form-submit" />
<p><a class="textlink" href="?q=user/password">Forgotten your Password?</a></p>

(The PHP code shown is for Drupal 7.)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.