Closed (fixed)
Project:
userplus
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
18 Nov 2006 at 00:10 UTC
Updated:
17 Mar 2007 at 00:05 UTC
Jump to comment: Most recent file
I'm trying to write a module that responds to changes in a user's role. I'm trying to do this in an implementation of hook_user(). I want to be able to quickly change the roles of the users using the table created by the userplus module. However, when I change roles using userplus, the hook_user function is never called. Shouldn't the userplus_admin_userperms_submit() function in userplus.module call module_invoke_all() after it writes the changes to the user roles to the database?
Is there some other way to do this that I'm missing?
Thanks
AC
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | userplus_edit_roles_0.patch | 1.91 KB | aclight |
Comments
Comment #1
marcp commentedI agree -- in this case, userplus should call user_save() for any users whose roles have changed -- user_save() calls module_invoke_all(), so I think that would be the safest thing to do.
If anyone has time to cut a patch for this, please do so. In userplus_admin_userperms_submit(), you'll need to:
1. Figure out which users have had their roles change
2. For each user that has had a role change, load the user, set the new roles, and call user_save()
Shouldn't be too hard...
Comment #2
aclight commentedWouldn't it also make more sense to do the actual changing of the roles via user_save, instead of directly writing to the database?
AC
Comment #3
aclight commentedHere's a patch that processes changes in user roles by calling user_save instead of directly writing to the database. It seems to work well for me, with the exception that it seems like it takes a while for the page to reload after I submit the page when I have 25 users/page listed. However, the devel module has short query processing and page processing times, so it could be my server or something.
Comment #4
aclight commentedComment #5
marcp commentedThank you for the patch! I am a bit slammed right now but will test this out soon. Moshe reported a different "feature" of userplus here http://drupal.org/node/88520 that might be right up your alley too. I've just been too busy to get to it.
Comment #6
aclight commentedUnfortunately I'm not using og on my site (and in fact I'm using nodeaccess, which I believe is incompatible with og), so I would have no easy way to test any patches relating to userplus and og.
Sorry
AC
Comment #7
marcp commentedA modified version of this patch has been applied to the new 5.x release of Userplus. Please test it out!
Comment #8
(not verified) commented