I would like to use Role Delegation to allow admins to assign user roles only when creating a user.
Once a user has been assigned a role, I'd like User Protect to trump any Role Delegation settings.

Is there a way to accomplish this with existing tools, whether its User Protect + Role Delegation or another set of modules?
I'd like to accomplish this through config, without implementing hook_form_alter or hook_user_*

If there is not a way, I'll re-categorize as a feature request.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DarkteK’s picture

Issue summary: View changes
JeroenT’s picture

Category: Support request » Feature request
Status: Active » Needs review
FileSize
1.93 KB

Patch attached fixes the settings overriden by Role Delegation.

I added the following fixes:

  • On the /user/%user/edit page, Role Delegation removes the ['account']['roles'] field and replaces it with ['account']['roles_change']. I added this field cfr. the Role Assign fix.
  • Added a hook_form_alter so the protections are also respected on the /user/%user/roles page provided by Role Delegation.
  • Added validation when the administration operations are used on /admin/people cfr. the RoleAssign fix.
JeroenT’s picture

Removed short array syntax so tests will run.

JeroenT’s picture

D8 version of this patch: #3057858: Role Delegation integration

cmseasy’s picture

I am using both modules 'User Role Delegation' and 'Userprotect'. In my case I do not want the override functionality as default. Please make it optional before commit.

With the correct setup in Userprotect I can achieve my needs, no need for an optional setup. The patch is usefull and in my opinion: commitable.

izmeez’s picture

@cmeasy can you change status to RTBC based on your findings?

izmeez’s picture

There was a similar patch committed to D8 with comment,

Great, this integration was still missing indeed.

in https://www.drupal.org/project/userprotect/issues/3057858#comment-13125588

Can someone using both modules confirm this is RTBC and ready for commit?

MegaChriz’s picture

7.x-1.3 has been released, moving this one to 7.x-1.4.