On my web site I want to have additional profile fields based on the users role. Some roles need certain profile fields, while others do not. And further it would be BAD to let all roles have all the profile fields.

...so...

I took a look at the profile.module and have a proposal which I want to swing by y'all before I implement it.

Database new table:

  • profile_roles: "fid" matching profile.fid, "role_id" matching the role id -- affording a flexible mapping between role and profile fields ... TBD: Need a way to declare the profile field is suitable for all roles
  • Alternatively ... instead of making a new table, the profile table could have a new column "roles" in which you enter the roles as a space-separated item. Then to check whether that profile field is suitable for the given role you simply do a LIKE query.

The visible changes would be in the admin area where profile fields are defined. Profile field add/edit pages would list the roles, letting the admin define which roles the profile fields are appropriate for.

Then there's several places to change non-visible behavior ... because there's several places where a list of profile fields are made for either display or edit. Those places need changes to ensure that fields are not displayed when the user doesn't have the right role for the given field. The main one of concern is the edit page for the users profile, to make sure that edit widgets are not made for profile/roles they do not have.

Comments

reikiman’s picture