If a user needs to create an account on a Drupal site, they go to the user registration page at “/user/register”. This page is the registration form on a Drupal site. You can customize it by adding or removing fields. But what if you want to have multiple registration pages?
Let’s say you have two different roles on your Drupal site and you need a separate form for each role. How would you build that?
You could handle all of this writing custom code but remember we’re using Drupal so means there’s a module that can handle this type of functionality and It’s called Multiple Registration.
The Multiple Registration module allows you to create individual registration forms base off a user role in Drupal. When you register on one of the forms, you’re automatically assigned the configured role.
In this tutorial, you’ll learn how to use Multiple Registration to create individual registration forms.
Installing the module
Download and enable the module with your preferred method.
composer require drupal/multiple_registration
drush dl multiple_registration -y
After downloading the module, click Extend in the toolbar and install it.
Create User Roles
The Multiple Registration module requires additional roles in order to display a customized registration form to each role. For the purpose of this tutorial, we’ll work with the example of a high school site with a registration form for parents and another for students.
The form for parents will have a field requiring information about payment methods and a billing address, while the form for students won’t have those fields, but instead of that will have a select list to vote for a sports team.
Click People, Roles, “Add role” in order to create the “Parent” role.
Repeat the process and create a “Student” role. After you’ve created the roles click the dropdown arrow next to the Parent role and choose “Add own registration page”.
You’ll be prompted to create a path for the Registration page for this particular role. For example, you could add “user/parent” as the path.
Create also a registration page for the other role (in this case “Student”).
Configure Registration Forms
Now that you’ve created the roles, it’s time to configure the registration form for each one.
1. Click Configuration, “Account Settings”, “Manage fields” and click the “Add field” button.
2. Choose the “List(text)” option and label it “Payment method”.
Enter in a few options into “Allowed values list” and set the “Allowed number of values” to Unlimited, since a parent can have more than one payment method and click “Save field settings”.
1|Cash 2|Credit Card 3|Check 4|Other
You’ll be redirected to the Edit tab, scroll down to the bottom of the page and check “Users with Parent role”. This configuration is provided by the Multiple Registration module. Click “Save settings”.
Add another text field for the Billing address and assign it to the Parent role.
Lastly, add a list field for a sports team election, this one will be limited to one choice. In the Edit screen of this field check “Users with Student role” and click “Save settings”.
Test New Registration Forms
Click “Log out” on the right of your screen and click “Log in” on the same spot once again. You will see two new tabs corresponding to the roles we’ve previously created.
If you can’t see the tabs then you’ll need to rebuild the site cache. Go to Configuration, Performance and click “Clear all caches”.
Check each form and make sure the fields were assigned properly to each form.
The Multiple Registration module provides the ability to create different registration forms without having to write code. Best of all, the role configured in the form is automatically assign when a user registers. This will save you time because you want have to manually assign a role.