You're building a new Drupal site that needs to handle two distinct types of users: Consumers and Service Providers. Each user group must have a unique role, profile type, and registration page. Users of each type should be able to visit your site, find the correct registration page, fill out their profile, and be granted an account with the correct role. Sounds easy, right?
Well, I recently found myself in this exact scenario. I was surprised to find that no combination of modules would exactly fit these requirements. This seemed like a great opportunity to build a legitimate, contributed module. Here it is: Profile2 Registration Path.
The purpose of this blog post is to tell a bit of that story, but more importantly, to show you how to do use it!
Drupal 7 core provides us with an easy means of adding fields to the user entity. Unfortunately, using the core method requires that we make said fields available to all users. That's not very useful for our current requirements. Enter Profile2.
Designed to be the successor of the core profile module, Profile2 gives us a great starting point. Let's take a quick snippet from the Profile2 project description:
Awesome. Now we can create a Consumer profile type and a Service Provider profile type. We're all set, right? Not quite. We need to make sure that our users can easily fill out these profiles during registration, and that they are granted the correct user roles after signing up.
By default, the Profile 2 module permits you to add fields from each profile type to the default user registration form. Unfortunately, there is only one user registration form. Thus, during registration, every user will be presented with fields from all of the selected profiles. If you have two profile types targeted at two different audiences, you cannot have two separate registration forms. Bummer.
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 specified profile type(s), and may have corresponding roles assigned to them upon account creation. Yay.
Here's a quick list of features taken from the Profile2 Registration Path project page:
So now that we have all of the tools that we need, how do we put it all together?
That should do it! You now have a site that can truly support the organic growth of multiple, distinct user groups.
I initially tried to collaborate with the maintainers of the Auto Assign Role module, which was my go-to Drupal 6 solution for this scenario. I submitted a patch here that would introduce a hook, which would in turn permit the integration of other modules with AAR. Unfortunately, nothing came of it. I still think this is a good idea, so feel free to petition for it!
I'm working on adding more features to Profile2 Registration Path, including:
Of course, all feature requests and code contributions are welcome!