Download & Extend

Roles added without calling user_save

Project:Registration codes
Version:6.x-2.7
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed

Issue Summary

This is a follow-up to #797602: Voucher code in tab profile doesn't assign role. The trouble with the new implementation is that there's no way for a module to react to roles being added to a user.

The user module itself calls user_save with only role information in the $edit array whenever roles are added or removed from the administer users page - cf user_multiple_role_edit(), and similar logic is used by the uc_roles module. So presumably the issues you discovered with simplenews, role_expire and profile would occur in those cases as well.

One way to circumvent this might be to pass a category which they don't recognize to user_save - e.g. "regcode" or some such. As far as I can tell none of those three modules will do their bad stuff if the category is unknown (unfortunately, it's not enough to pass NULL because role_expire deletes its entries when $category is NULL or 'account'.

If you don't want to do that, another option would be to provide a "regcode_role_update" hook, but then any existing modules counting on hook_user('update'...) to let them know that roles have changed would have to be refactored to process the new hook.

Please let me know what you think - as this is a deal-breaker for me with this module - I have to be able to respond to changes in user's roles.

Thanks.

Comments

#1

Status:active» postponed

I don't have time to muck around with this - if you can supply a patch then I'll look at it.

nobody click here