Please see this change regarding automatic role assignment.
http://cgit.drupalcode.org/regcode/commit/?id=be9321a

I just noticed that it broke my code that reacts to a role getting added to a user. Adding roles to a user directly via the database does not seem like the drupal way of doing things.

Comments

ayesh’s picture

You are right these DB queries need to be replaced with user_multiple_role_edit(). Should be an easy patch.

There were many API incompatibilities in the 7.x-1.0 so I'm planning a rewrite as soon as I have some time.
But this surely is a big and can't wait for the 7.x-2.0.

davemaxg’s picture

Thanks Ayesh for responding so quickly and for all your hard work on this module!

I did some looking into this function and I think another approach may make more sense because if a regcode has multiple rules, there may be a need to assign multiple roles to a user. Saving after adding each role is some unnecessary overhead. This function is best suited for adding one role to multiple users. I did implement it as a patch in case anyone needs it, but it's not the best solution IMO.

David

  • Ayesh committed c22badf on
    Issue #2502599 by davemaxg, Ayesh: Adding roles should be done using...

  • Ayesh committed c22badf on 7.x-2.x
    Issue #2502599 by davemaxg, Ayesh: Adding roles should be done using...
ayesh’s picture

StatusFileSize
new922 bytes

Thanks Dave.
Your patch was unfortunately based to the Drupal root. It however does the job, so I went ahead and committed to the current head.

The 6.x-2.x branch did not need any changes because it added the roles to user object directly before saving. This will come with the 7.x-1.4 release. Thanks a lot Dave.

ayesh’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

davemaxg’s picture

This line is preventing the role assignment in user_multiple_role_edit from working

$account->roles[$rule['role_id']] = $rule['role'];

Just remove it and everything is working again.

Thank you Ayesh!