Has anyone played around allowing users to add themselves to one or more "public" roles (groups)?

Let's say there are 3 roles:

plumbers
electricians
carpenters

The user would be allowed to select one, which would enable certain functionality of interest to that particular role (group) as defined in "access control."

This seems somewhat straightforward. The one thing required is to distinguish between "public" roles and those used for security and access. My thought is to add a column ("public") to the role table as a tinyint data type. Each role is defined as "yes" (1) or "no" (0). The rules form (admin/access/roles) and subsequent rule edit form (admin/access/roles/edit/) would need to be modified to support the extra field.

Does anyone have an opinion on this idea? Is there already a "built-in" way to make this kind of distinction?

Thanks!

Comments

reikiman’s picture

I think the use case is larger than what you say. Currently to add someone to a role, the administrator(s) do so by manually editing the users profile. That's find unless you have thousands of users and want to award several kinds of roles to them.

That is, if your model for roles is: unregistered, registered, editor

Then you can assign the editor role to a few select people, and use the automatic assignment to the registered role that's built into drupal to take care of the rest.

In my case I am building site(s) that will support interaction between the general public and certain professionals with specific training. My model for the roles is: unregistered, registered, practitioner, editor

So....? I don't think my model is satisfied by the one you propose. That's because I want a review process before allowing someone to join one of the the practitioner roles (there could be more than one practitioner role), because I want to have some certainty the person claiming to have the training required to be a practitioner actually do have that training.

- David Herron - http://7gen.com/

johnhanley’s picture

David, thanks for sharing your thoughts.

My application is pretty straightforward although I left something out in my original post. Specifically the ability for the user to select a role. I'm going to accomplish this by adding a custom profile select input containing the available user-selectable roles. However, I don't want to enter a static list of items so I'm going to modify the profile module to support database query entries.

I'll keep you posted on my progress and any/all other comments are welcome regarding this topic.

mork’s picture

I'm approaching a project that will need something like this as well. My thoughts were to throw it into a seperate custom module and emply the _user hook to add a custom field to the user profile.

Of course, I haven't actually gotten around to trying this to see if it works yet. This becomes a little more tangled with access control based on that field though.

johnhanley’s picture

Mork, you could easily create your own custom module to handle the role assignment, but modifying the profile module might be just as easily and intergrates nicely

The profile module needs to support name/value lists from a recordset. This could be as simple as a textarea for a admin-defined query.

To be continued...

johnhanley’s picture

This is just a quick follow-up for anyone interested in doing something similar as described in my original message

I ended up using hook_user to add the role selection to the user registration from. A good example of how to do this is in the profile module.