Role delegation showing up on profile created tabs and wiping out assigned roles
| Project: | Role Delegation |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
I have some profile fields under their own tab in the user page. Role Delegation is now adding the "roles" section to the profile tab, and is not selecting any pre-existing assigned roles to the user. This means the user, from being very privileged goes to "authenticated user" if they save any profile changes from the profile tab. I can't see how I can easily fix this in the code, it looks like your code is mangling the user page whether or not it's the "base" user page, and for some reason (I can't see why) it's not picking up it's roles when it's not on the "base" user page.
To recreate, simply add a new profile field, with it's own category. try and edit that profile field on a user granted privileges, and you'll see that the assigned roles disappear.
Thanks

#1
OK. I spent some time, and figured out that using hook_form_alter is not going to respect profile tabs.
Attached is a diff for what I think is the way you're supposed to do it.
Hope this helps
Christian
#2
Any development on this? I have a production site where this issue is causing confusion. We'll apply the patch and test if it would help all.
#3
Applied the changes in this patch - disabled/re-enabled the module. Did not find the problem addressed / corrected;
Roles show up on each profile category page, entirely empty, as title of this issue describes. This occurs for any user granted delegation permissions. Changes over-ride actual existing values, as described above if saved.
#4
I see this as well. I will test the patch and report back soon.
#5
The patch from djsmeg fixed this issue for me (roles no longer show up in profile tabs other than account, and thus they don't get wiped out when the profile is saved), and I've simplified the patch a bit (the only change being that hook_form_alter() is completely removed).
I removed the hook_form_alter() implementation because it didn't appear to do anything (someone correct me if I'm wrong); the code after applying the original patch (and the code that I removed in the new version of the patch) is below:
/*** Implementation of hook_form_alter().
*/
function role_delegation_form_alter(&$form, $form_state, $form_id) {
// Only alter user form when user can't assign permissions without Role Delegation.
if ($form_id != 'user_register' && $form_id != 'user_profile_form') {
return;
}
if (user_access('administer permissions')) {
return;
}
}
#6
The patch in #5 solved this problem for me. Can we get this patch committed to the module?
Cheers,
Ben
#7
FYI for anyone having this problem and wanting a possibly upgrade friendly work around:
A new custom module dcpl_misc.module:
<?php
function dcpl_misc_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'user_profile_form':
// for this to work, wee need to run this SQL: update system set weight = 10 where name = 'dcpl_misc';
if (!array_key_exists('account', $form)) {
unset($form['roles_assign']);
}
break;
}
}
issue the following SQL:
update system set weight = 10 where name = 'dcpl_misc';#8
Patch in #5 worked like a charm for me too.
Please roll it into the next relase if possible.
Cheers! And thanks for all your hard work on a great module!