#7784 closed defect (bug) (fixed)
Pass old user data to profile_update action
| Reported by: | AaronCampbell | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.7 |
| Component: | Administration | Version: | |
| Severity: | normal | Keywords: | has-patch needs-testing |
| Cc: | Focuses: |
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
@
18 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
@
15 years ago
- Keywords needs-patch added
- Resolution fixed
- Status closed → 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
@
15 years ago
- Keywords needs-patch removed
- Resolution → fixed
- Status reopened → closed
This ticket was closed on a completed milestone. Please open a new one if there's a problem.
#6
in reply to: ↑ 4
@
15 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
The patch should be completely backward compatible, and would allow a plugin to pull the current user data and compare it to the old.