#7784 closed defect (bug) (fixed)
Pass old user data to profile_update action
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
If we pass the old user data to the profile_update action, plugins could trigger actions based on CHANGES to user data.
Attachments (1)
Change History (8)
#2
@
15 years ago
For anyone that grabbed the patch already, it was messed up. I made the diff, and pulled out the other changes that didn't apply to this ticket. I took out too much. The replacement is based on a nice clean slate.
#4
follow-up:
↓ 6
@
12 years ago
- Keywords needs-patch added
- Resolution fixed deleted
- Status changed from closed to reopened
Problem still exists in version 3.1.
The bug is related to the fact that "accepted_args" of "profile_update" is 1 in all cases and thus never passes the "old_data" to the hooked functions.
A clean way to do this would be to change line 486 of "wp-includes/plugin.php"
from:
call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
to:
call_user_func_array($the_['function'], $args);
Instead of slicing the args array from 0 to X arguments.
#5
@
12 years ago
- Keywords needs-patch removed
- Resolution set to fixed
- Status changed from reopened to closed
This ticket was closed on a completed milestone. Please open a new one if there's a problem.
#6
in reply to:
↑ 4
@
12 years ago
Replying to crazycoders:
The problem is fixed. You just have to specify how many parameters your function expects. Try something like this:
function profile_update( $user_id, $old_info ) { // Both parameters as expected } add_action( 'profile_update', 'my_profile_update', null, 2 );
Notice that the 4th parameter sent to add_action is the number of parameters. It defaults to one but by specifying 2 I get both.
The patch should be completely backward compatible, and would allow a plugin to pull the current user data and compare it to the old.