Custom role-dependent user profiles
NOTE: This tutorial is for Drupal 5 only. For Drupal 6, take a look at the Content Profile module.
For the Quebec Chronicle-Telegraph website, I was asked to create a system whereby users could sign-up for one of three types of newspaper subscription, and at the same time, get a user account with access to premium content. Each of the three subscriptions would require different information from the user. This requirement precludes the use of the regular core profile module (that module provides one set of profile fields for all roles).
After some searching on drupal.org and some Drupal user sites, I figured out a way to do this using Role Signup and Node Profile modules as the two main modules. There were several other supporting modules that I used to fill in a few of the "gaps".
So how exactly did I do it? Read on and find out...
Modules used
- Role Signup
- Node Profile
Requires: - Auto Node Title
Requires: - CCK
Extra CCK widgets
Module modifications
Role Signup
This is a great module, but we needed some extra features. By default, the module simply shows the various roles that you are allowed to choose from. However, we wanted to have a description for each role - subscription cost, what you can do with this type of subscription, etc.
What I did was add in some code that allowed descriptions to be added to each role. These descriptions could be entered through a settings menu in Administer > Settings > Role Signup. I also added the ability to change the name of the role shown on the registration page. This allows you to keep simple role names, but show a more descriptive label for the role e.g. the citizen role can be displayed as Regular subscriber. One final modification was the ability to sort the user roles in various ways (sorry, I didn't use weights, as I could achieve the desired sort order with the options I provided). I have submitted a patch for this functionality, by the way.
CCK widgets (optional)
I modified the Address and Fullname widgets a bit as some of the code that was outputted wasn't quite up to spec. If I could do it through theming, I did, but some of the code was hardcoded.
Configuration
- Install and activate all of the above modules - the extra CCK widgets are optional.
- Configure Role Signup
- select which roles you want shown on the selection screen
- go to admin/user/access and tick the box for the desired roles
- add descriptions and titles, and choose the sort order if you use the above patch.
- Create a new content type using CCK, for each role:
- open the Automatic title generation fieldset
- check Automatically generate the title and hide the title field
- create a pattern for the title
- enter your Name and Type data
- leave the Title alone as Auto Node Title will take care of it
- you can leave the Body field as is, or remove it - I usually remove it, so that I will have more control of the fields
- in Default options, uncheck Promoted to front page
- enter "1" for Maximum population
- tick Use this content type as a nodeprofile for users
- disable comments
- Save your node type
- Click edit to open up your new content type
- Add and configure the fields you want to your node type
- Click on Node profile and tick the following options:
- Integrate this node profile with user categories
- Show this node profile during user registration
- select the role(s) that will use this node type
- Display it as full node view
- Include an edit link to the display (default)
- Include an add link to the display if they haven't yet (default)
- Click Update
- Finally, go to Access Control and allow the different roles to Create & Edit the node types that relate to them
That's it! Logout and go to user/register to see what happens. You should see a list of your roles (with descriptions if you used the patch). Click on a role and you should see the node type you just created for that role. Fill it in, and an account should be created for you. The details you entered should be visible on the My account page. They can be edited by clicking the Edit link just above the profile, or by going through the regular profile edit tab and selecting the node type.
If you need to customize the layout of the various fields, you will have to do some theming. You can use the Contemplate module to do this, or create a node-nodetype.tpl.php file for each node type.

I didn't understand Role
I didn't understand Role Signup part.
Its broke
I can't get it to work!
When I go to edit the Node Profile settings in the content types, it doesn't allow me to select the roles that will use the node type. Also when I go to the Create New Account link, it is blank except for the "Please select what type of account you would like:" text. There are no roles to select from.
Any help would be appreciated?
Make sure you have done all
Make sure you have done all the items in Step 2, in particular, the second part where you select the roles on the Access Control page. If you don't do this, nothing will work.
Thanks, that got it working,
Thanks, that got it working, only hting now is that no matter which role a user tries to register for, it takes them to the first one. It was working to begin with, and now no matter which role I try and change the register form to, it only allows sign up for one role.
It defaults to that one role (ie when I click create new account, it will no longer show the selection screen for roles) and when I try to change the role, it goes back to the first one (eg, if i had teachers and students, i would go to register as a teacher, btu it would take me back to registering as a student).
Playing with the settings in LoginToboggan changed the role to which it defaulted to, but I completely uninstalled the LoginToboggan module and removed the module from the file directory and it's still doing it. Worse now, as at least when LoginToboggan was on, it would at least come up with the slection screen for the roles.
Any idea of how to fix this?
Same problem
I've got the same problem -- no matter which they choose, it always goes to the first one. I'm not running LoginToboggan.
Versions
Can you post the versions of all the modules you are using - the ones related to this part of your site. Maybe one of them has changed the way it does things and my recipe no longer works properly.
Versions, as requested
Node Family 5.x-1.4
Node Profile 5.x-1.4
Role Signup 5.x-1.x-dev
Automatic Nodetitles 5.x-1.2
Subform Element 5.x-1.4
What else do you need to know?
Thanks in advance!
Hall
Notifications?
Also, I checked the box "Notify me of follow-up comments posted here." but there's nowhere to enter an address.
My bad.
I had disabled leaving email addresses and such to cut down on the stupid spammers. I just put it back, and I'll deal with the odd spammer that gets through.
The Links are Broke
Hi Dave,
I was able to follow your instructions and got everything working perfectly. However, I was conducting some more testing and things just stopped working. When I go to register I can see my available profiles, but now when I click on them it simple refreshes the page (re-displaying my available profiles). The url will change from "user/register/role?destination=user%2Fregister" to "user/register/role/4" (or "/3" whatever role I pick) and then back to the previous url. So I never get to the part where I can actually fill in my information and sign up. I went through your tutorial again and everything seemed to be set up correctly.
The only things that may have changed were my adding the user_delete and user_cancel modules. I removed them, but it didn't help. This is my first drupal site so forgive my naivety if this is an obvious fix.
Thank you for your time,
Brandon
Do you have any other login
Do you have any other login modules installed, eg. logintoboggan? These can interfere with the setup. Other than that, I don't really know what would have caused that problem.
Same issue as gregg
"Everything works exactly as described but when I login with one of the new signed up members I dont see any of the options that should be available for the relevant role. When I check the users page I see that it has not actually assigned the role to the new user and the Roles field is left blank."
Same thing happens to me! Please help me!
Are you using the
Are you using the Logintoboggan module? If so, there is a conflict with it for some reason.
very good
Hello!
Congratulation to you fr such a god thing. And to me for almost adopting this for a website.
However, I am stuck, with, perhaps its CCK issue:
For all roles, there is a Agreement Text before and then a I AGREE/I DO NOT AGREE radio button. there are 2 for this. Any idea to handle this?
No idea
I don't know where that text comes from, but it sounds like you have another module in place that is inserting it. You might want to take a look at the issue queue for that module to see if its a known problem.
Automatic Generation of Title
You must also be using this module: http://drupal.org/project/auto_nodetitle, so here's the link.
Thanks for the great tutorial. I think I'll link to it from Drupal.org somewhere.
-jmjohn
patched version of Role Signup vs Autoassignrole
Hi,
Thanks for the really useful tutorial. This is just what I need for my site to try and distinguish service providers from service users.
I couldn't get the link to you patched version of Role Signup to work.
As with your example and with Gregg above I need users to pick their role before going the page with their profile on as I need to ask each user type different information for their profile. How can I do this with auto assign ? (since I can't get your version of Role Signup) I've had a look and can't work out a viable option set the works for this module.
I did wonder about e Membership types and registration modification which Gregg Mentions above but then how do I get the profile to show just the bits I want?
Any suggestions?
Link fixed
Sorry about the broken link. I recently moved the site to a multisite setup and the path was hardcoded.
I had a look at the nf_registration_mod module a little while ago, but found the Role Signup method a lot easier to work with. So I don't really know how to work with it properly.
No idea how to get Auto Assign to use different profile pages - never used the module myself.
Role Signup - blank list
Hi Dave
Thanks for fixing the link. Now got your patched module. Followed your directions but when I try to sign up the role sign up page doesn't give me any role types to choose even though I have created these.
Also how were you able to get it not to list anonymous role and authenticated user role ?
Thanks for your advice.
Ian T
Role Signup - blank list - solution
Answering my own question ... but useful tip for others
The answer is that you need to enable access control (/admin/user/access) for the rolesignup module for the roles that you want people to be able to sign up to.
IanT
the link to the patch 1.6
the link to the patch 1.6 appears to be broken?
Login Toboggan conflict
I found out that this is because of a conflict with the Login Toboggan module http://drupal.org/node/129411
The tut works perfectly
Thanks
Good to know
Good to know. Thanks for posting a follow-up here. Hopefully it will help others too.
Doesnt assign role...
Hi Dave
I have followed this tut very closely and used the patched version you have provided but have found an issue that I am not sure if it is a problem with Role Signup or if it something I am doing wrong.
Everything works exactly as described but when I login with one of the new signed up members I dont see any of the options that should be available for the relevant role. When I check the users page I see that it has not actually assigned the role to the new user and the Roles field is left blank.
Can you think why this could be?
If I cannot solve this issue then I think I am going to try the http://drupal.org/project/nf_registration_mod module although it seems quite a bit more complex than I need.
Thanks
Autoassignrole
Hi,
This is an excellent tutorial but I see that the rolesignup module has been depreciated in favour of the http://drupal.org/project/autoassignrole module.
The autoassignrole puts the roles selection form on the same page as the signup form making it impossible to change the form and required details dependent on the users choice. Have you worked with this module before? Do you have any advice on how a similar technique could be used with the autoassignrole. My php is pretty basic still but would love to know if this is possible to do.
Thanks
Thanks
Thanks for pointing this new development out to me - I wasn't aware of it. I haven't actually used the autoassign module yet, so I'm not sure of all its nuances. Just by browsing through the code, it seems to offer fairly similar options as the role_signup module.
You should still be able to use nodeprofile to setup separate user profiles. However, I'm not sure that you will see them on the user registration page anymore. So you might have to untick the option to use it on the registration page.
How about including registrations approval settings
Hi Dave,
Finally after losing hope of finding how to make custom roles registrations I found your excellent tutorial. I have a question, how you could extend the above procedure to enable specific approval requirements such as automatic/administrator approval?
Thanks in advance and kudos on your excellent tutorial!
Best regards,
Newbee
Maybe I'm missing the point
Maybe I'm missing the point of your question, but surely you could simply select the appropriate setting from the user admin > user settings page?
What is meant by "create a pattern for your title"?
Hi Dave,
In #3 above, I understand everything except for "create a pattern for the title". What am I supposed to do with that? I searched around the Drupal forums but couldn't find any explanations. Can you please elaborate on what this is for and also provide an example?
Thanks in advance and thank you so much for your excellent tutorial!
Best,
Walt
By "pattern" I mean how you
By "pattern" I mean how you want the title to look like, using the tokens provided (look just below the title field for "replacement patterns"). I usually do something like: [author-name] [author-uid].