Custom role-dependent user profiles

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...

UPDATE (22/03/2008): The Role Signup module has been deprecated in favour of the Auto Assign Role module. However, the role selection is now on the same page as the profile fields, so you cannot use it with nodeprofile to get different signup forms at this time. Because of that, I am providing the patched version of Role Signup here.

Modules used

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

  1. Install and activate all of the above modules - the extra CCK widgets are optional.
  2. 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.
  3. 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
  4. Click edit to open up your new content type
  5. Add and configure the fields you want to your node type
  6. 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)
  7. Click Update
  8. 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.

Posted in:

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].

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <b> <i> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4> <blockquote> <img>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is to block spam bots and check if you're human
6
G
G
m
u
X
Enter the code without spaces and pay attention to upper/lower case.
magnanimous-junior