Opened 15 years ago
Closed 15 years ago
#10716 closed enhancement (fixed)
New hook for user role change
Reported by: | usermrpapa | Owned by: | |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | normal | Version: | 2.8.4 |
Component: | Role/Capability | Keywords: | has-patch |
Focuses: | Cc: |
Description
It would be nice to have an action to hook into for user role changes. We have a plugin that cares about role changes as a way of controlling features/access in a plugin.
I can grab role changes just fine if they are made on the users profile page (user-edit.php) via one of the profile hooks, but if the changes are made to roles via the user bulk changes editor (users.php), there isn't a way (unless I have just missed it) to know that any user roles were changed.
I have opened this ticket for 2.8.5, but not sure how its potentially affected by the upcoming roles/capabilities changes slated for 2.9.
Attachments (2)
Change History (14)
#2
@
15 years ago
When the hook was fired, we would execute some additional code in our plugin to take action based on the role change for that user.
Personally, I wouldnt want to affect the role change itself or any cached permissions values.
#3
@
15 years ago
Probably should know how to create a patch, but I dont. I think its pretty much as easy as adding a
do_action('user_role_update', $user_id);
or some other more appropriate name in
wp-admin/includes/user.php (around line 80 in wp 2.8.4)
and
wp-admin/users.php (around line 67 in wp 2.8.4)
my wp 2.9 test site is a bit out of date (getting ready to release new version of our plugin), but guess I should bring it up to date.
#6
@
15 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Future Release to 2.9
okay, lets try adding a patch for this (be gentile) ;)
this is against trunk, rev [11898]
would be nice if applied to the 2.8 line too...
#7
@
15 years ago
I have attached an patch that is an alternative to roleaction.patch
.
My patch runs the action as part of the WP_User::set_role()
function, which I think is a better place.
The action also passes the user ID and new role name as part of the action.
#9
@
15 years ago
Is there any chance in getting this one line patch committed in time for WordPress 2.9?
Thanks very much.
It shouldn't be affected by the capabilities changes in 2.9, infact, it'll probably be easier (As it'll be a role transition, rather than a roll add/roll removal which is currently possible).
How are you planning on using the hook? To change cached permission values?
Milestone: Future release pending patch for enhancements, Current-trunk upon patch being added for consideration, point release back-porting at commiters discretion. (Generic reply for when I change the milestone)