Registration of multiple user roles from different registration pages with Profile 2 module

Registration of multiple user roles from different registration pages with Profile 2 module

Drupal got a great user registration system and management but it can be made awesome with Profile 2 and Profile 2 Registration Path modules.

The problem

Drupal 7 allow us to add field to user registration form using "admin/config/people/accounts/fields" page and anonymous user can fill these fields from user registration form. But these fields will be same for all user roles, hence providing the same privileges to all registered users. Take a scenario in one of your Drupal development project where you have two roles teacher and student and you want them to have different user registration fields and privileges.

Our Solution

For the above scenario "Profile 2" and "Profile2 Registration Path" modules allow you to create two different user registration form with different fields for both user roles. It also allows you to assign different roles according to registration form and have different privileges on their respective accounts.

The Implementation

To make the above scenario work within your Drupal development project, first you need to enable Drupal Profile 2 module and Profile2 Registration Path module.

After enabling both Drupal modules add two different user roles teacher and student for which you need different user registration forms. For this, you need to create two profile type for these user roles from "admin/structure/profiles/add" page. Here add profile type for teacher role called "Teacher".

Enable unique path registration option which is provided by Profile2 Registration path module. This option allow us to set unique url path like "teacher/register" in which teacher registration profile form will open. Now select a role which will be assigned to the user on registration based on registration path provided above and save profile type.

Now in "admin/structure/profiles" page, you have teacher profile type. Go to manage fields page "admin/structure/profiles/manage/teacher/fields" to add field to teacher profile type such as teaching field, previous school and mobile. And these fields will be shown on teacher registration page.

Following the above step you can create student profile type with unique registration path "student/register". And add fields to student profile type such as gender and class.

Now you have got two user registration forms for teacher and student user roles with different registration paths "teacher/register" and "student/register". And appropriate role will be assigned to user based on registration path. Profile2 registration path module also provides options such as:

  • Custom title for login, register and forgot password pages.
  • Display a confirmation message to user after successful registration.
  • Wrapping profile fields in a fieldset.
  • Showing profile type fields to core user registration forms and administrator add user forms.
  • You can also assign profile type to Drupal core user registration path "user/register" from unique registration path option.

Using the above information you would be able to assign different user roles/privileges using seperate registration forms at different urls.