I'm not sure if this is related [or maybe opposite?] or #2053097: Overided by Role delegation
I am using role_delegation to help set up a "membership coordinator" role that can create new users and assign roles to them, etc.
autoassignrole seems to be working when an admin user creates a new user, but it is not working when the membership_coordinator role creates a new user, although the membership_coordinator has permission to assign roles.
I am seeing the same behavior (only works when admin user creates a new user) with a similar module that I also tried registration_role and filed a similar issue there #2118679: conflict with role_delegation? RR only works by admin user.
So I guess now I wonder if the problem lies in role_delegation instead??
Comments
Comment #1
WebSinPat CreditAttribution: WebSinPat commentedAha. I think I see where the miscommunication with role_delegation stems from.
it seems that role_delegation and autoassignrole work by creating new form elements on the user_reg form, and those new elements do not know how to talk to each other. (sorry, I don't know the drupalspeak to describe this.)
When role_delegation adds role assignment options to the user_registration form, it uses
$form['account']['roles_change']
whereas autoassignrole uses:
$form['autoassignrole_user']['user_roles']
I have no idea how to go about reconciling the difference, but maybe somebody else does.
Comment #2
mike.davis CreditAttribution: mike.davis commentedHi @WebSinPat,
I have had a look at this and it seems that the issue comes when the auto assigned role within this module is also in the list of roles that can be selected by a user in the role delegation module.
This is because the roles selected in the role delegation module override what has been auto assigned.
This would need to be something that the role delegation module handles checking as the hook_user_presave is called on the role delegation module after the auto assign role module.
Thanks
Comment #3
mike.davis CreditAttribution: mike.davis commentedHi @WebSinPat, I have raised an issue with the role delegation module (https://www.drupal.org/node/2292905) to look at this, so this might help you when it gets fixed.
Comment #4
mike.davis CreditAttribution: mike.davis commentedJust been thinking on this more and not sure if it might be something that auto assign role can do to pre-select the auto assigned role(s) on the user form when using the role delegation module.
Will have a think further and look at these both to see where might be best to fix this.
Comment #5
mike.davis CreditAttribution: mike.davis commentedHaving had a look at this I think that this is something that role_delegation will need to deal with, as the form alter hooks will get called for autoassignrole before role_delegation so autoassignrole can't make any changes to the form.