Integration with Role Help
deggertsen - September 14, 2009 - 20:30
| Project: | User-Selectable Roles |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
When people are registering there appears to be no way to put in a description for the roles that they can select. It would be extremely helpful if we could make it so that if you have http://drupal.org/project/role_help installed you can view the descriptions attached to the roles when registering. It would be great if this was part of User-Selectable Roles core but I thought pulling the descriptions from role help might make things easier.
Thoughts? Does something like this already exist?

#1
I understand the usefulness of role descriptions, but I'm not inclined to add them directly to User-Selectable Roles.
Role Help looks interesting, but the D6 version is still in development.
You know, role descriptions could easily be added at the template level. Having them editable via an admin interface is nice, but wouldn't be completely necessary since they are unlikely to change very often. One could loop through the user-selectable role form elements and output the role description for each. I can provide a syntax example if need be.
#2
A syntax would be helpful as I'm still an amateur programmer. Sounds like a decent solution. I definitely like the idea of being able to display role descriptions in one way or another. I know for a lot of end-users it would be nice to have an easy admin interface to edit them but you are right that they are unlikely to change so it wouldn't be a big deal to simply put them in once. So if you could give me an example I would really appreciate it!
#3
Here's a quickie example of how to add descriptions for each user-selectable role on the user registration page. To use:
1) Follow the steps outlined in this excellent blog article to create a custom registration template.
2) Replace the example template content shown in step #2 with the following:
<?phpif (isset($form['user_selectable_roles']['user_selectable_roles']['#options'])) {
foreach ($form['user_selectable_roles']['user_selectable_roles']['#options'] as $key => $value) {
// $key is the role ID
switch ($key) {
case 1:
$form['user_selectable_roles']['user_selectable_roles'][$key]['#description'] = t('This is the description for role #1.');
break;
case 2:
$form['user_selectable_roles']['user_selectable_roles'][$key]['#description'] = t('This is the description for role #2.');
break;
case 3:
$form['user_selectable_roles']['user_selectable_roles'][$key]['#description'] = t('This is the description for role #3.');
break;
}
}
}
?>
<div id="registration_form">
<?php
// outputs the entire form
print drupal_render($form);
?>
</div>
The same can easily be done for the profile edit page.
This issue has me thinking that it might be useful to expose the user-selectable role selections on the user profile view page. I might consider adding that option in a future release.