We have admins who don't have privileges to assign roles, but who can create users. We wanted the users created by them to have a role assigned, but not users who are created by other means. Attached is a patch to achieve this – with the patch you can leave autoassignrole_auto_active setting disabled and only enable autoassignrole_admin_active.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitgoyal’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.Looks good to me!

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

dmadruga’s picture

Status: Fixed » Needs review

The problem here is that when autoassignrole_auto_active is enabled AAR will set the automatic roles when the admin creates an account even if autoassignrole_admin_active is disabled.

This IF is always TRUE when autoassignrole_auto_active is enabled.

if (variable_get('autoassignrole_auto_active', 0) || (variable_get('autoassignrole_admin_active', 0) && user_access('administer users')))

I changed the IF to:

if ((variable_get('autoassignrole_auto_active', 0) && !user_access('administer users')) || (variable_get('autoassignrole_admin_active', 0) && user_access('administer users')))

mike.davis’s picture

Issue summary: View changes
Status: Needs review » Fixed

This change makes sense and has been commited

  • mike.davis committed 6382eff on 7.x-1.x
    Issue #1795536 by dmadruga: Only auto-assign roles to accounts created...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mike.davis’s picture

Status: Closed (fixed) » Needs review
FileSize
1.21 KB

The automated tests were failing due to the variable not being set by the test.

mike.davis’s picture

Status: Needs review » Closed (fixed)

This is strange that the test is failing on the test bot as running the tests locally were broken & fixed by this patch and retesting it on simplytest.me were again broken before applying the patch but worked after applying the patch.

I'm going to commit this in to see if this helps with the other patches that are failing.

Status: Closed (fixed) » Needs work

The last submitted patch, 7: autoassignrole-1795536-7.patch, failed testing.

mike.davis’s picture

Status: Needs work » Closed (fixed)

I am closing this now as this patch needed to be applied in order to fix the 7.x-1.x branch so that the automated tests could run to completion.