Can users change their own role?
everydayjones - January 18, 2009 - 22:28
| Project: | Auto Assign Role |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | won't fix |
Jump to:
Description
If a user signs up and doesn't select a role, can they go back into their account and select the role? I don't see that option in the users Account settings.

#1
i would need this too ... i think this could be very usefull.
can you add a checkbox in the module where you can activate if users can change their roles or not? that would be great!
i would need it for D6
greets
#2
i found a solution for that if someone is interested in it ... for D6
greets
#3
Post it
#4
Yes, I'm also looking for it. Please, post.
#5
hi
just delete or comment out the lines marked with "modified by gr4phic3r" in autoassignrole.module
/*** Implementation of hook_user().
*/
function autoassignrole_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'insert':
case 'update':
/* modified by gr4phic3r
if (_autoassignrole_settings('user_active') == 1) {
*/
$roles = array();
$user_roles = _autoassignrole_settings('user_roles');
if(is_array($edit['user_roles'])) {
foreach ($edit['user_roles'] as $k => $v) {
if ($v != 0 && in_array($k, $user_roles)) {
$roles[$k] = $v;
}
}
$edit['roles'] = $roles;
}
/* modified by gr4phic3r
elseif($edit['user_roles'] != '') {
$edit['roles'] = array($edit['user_roles'] => $edit['user_roles']);
}
}
*/
if (_autoassignrole_settings('auto_active') == 1) {
$auto_roles = _autoassignrole_settings('auto_roles');
foreach($auto_roles as $k => $v) {
$edit['roles'][$k] = $v;
}
}
$account = user_load(array("uid"=>$account->uid));
break;
greets
#6
A lot of thanks... I've marked it as a patch to see if it can be done in next version.
#7
Please roll this as a real patch http://drupal.org/patch/create
#8
Wouldn't be easier just mark it as "Required" than patching the module?
This way if someone submits without choosing a role they'll get a "field is required" message.
Just my thoughts
#9
What is the status on this?
This should definitely be an option included, but maybe it should use the variables that is under the "Allow user to choose" fieldset on the AutomaticAssignRoles settings page.
#10
Still looking for a decent patch for this.
#11
It appears this is in the beta 3...
I think the "case 'update':" is missing too.
#12
subscribe,
Do this pach is in the last dev version of July? I can't find how to allow users to change their roles.
#13
This would only work if the user is allowed to make the selection during registration. It looses viability when a user is presented with multiple paths or content types that can function as a registration form. Each path might present a node with specific cck fields that are required. Simply providing a mechanism for the user to switch their role would not account for all of the possible variations. I'm not entirely convinced this is something I am going to be able to provide.
I am going to mark this as won't fix unless a decent patch is provided that can be prooven through simpletest
#14
@cyberswat
"This would only work if the user is allowed to make the selection during registration." It's what I need! :)
#15
Hello, Users can choose a role on registration page but can't change their role after... It doesn't make sense.
My users HAVE to choose a role (only one) on registration page but they could change it later...
This feature is impossible?
#16
@juno it's not impossible. I'm sure cyberswat would accept a patch for this functionality.
Have you looked at http://drupal.org/project/role_control?
Setting back to won't fix since cyberswat's reasoning still applies.
#17
@control
I didn't take a look on this module. i would say: Again a module not maintained...
I'm not a developper it's not safe for me to use it....
The problem with Drupal is that a lot of modules have to be maintain to avoid problems.
#18
It's not unsafe per se. Unless there are outstanding security bugs listed, it is just a matter of it working correctly. Try it and test everything. If it works correctly for your needs, then there isn't an important reason you can't use it.
#19
I really want this functionality. With the current system a user has only one shot to choose the appropriate role. If they screw up and choose the wrong one their stuck with it unless they contact the admin and request a change. I really want users to be able to change their role after the fact. Maybe I'm doing something wrong, but commenting out parts of the code as suggested n #5 did not seem to achieve this.
I don't have the chops to program this myself, but I'm willing to contribute $50 USD towards seeing this implemented.
-Ista