Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#7 | autoassignrole-1795536-7.patch | 1.21 KB | mike.davis |
autoassignrole_admincreated.patch | 1.32 KB | ZeiP | |
Comments
Comment #1
amitgoyal CreditAttribution: amitgoyal commentedLooks good to me.Looks good to me!
Comment #2
DamienMcKennaCommitted.
Comment #3
dmadruga CreditAttribution: dmadruga commentedThe 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.
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')))
Comment #4
mike.davis CreditAttribution: mike.davis commentedThis change makes sense and has been commited
Comment #7
mike.davis CreditAttribution: mike.davis commentedThe automated tests were failing due to the variable not being set by the test.
Comment #8
mike.davis CreditAttribution: mike.davis commentedThis 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.
Comment #10
mike.davis CreditAttribution: mike.davis commentedI 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.