Make WordPress Core

Opened 16 years ago

Closed 13 years ago

Last modified 10 years ago

#7784 closed defect (bug) (fixed)

Pass old user data to profile_update action

Reported by: aaroncampbell's profile AaronCampbell Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch needs-testing
Focuses: Cc:


If we pass the old user data to the profile_update action, plugins could trigger actions based on CHANGES to user data.

Attachments (1)

7784.001.diff (719 bytes) - added by AaronCampbell 16 years ago.

Download all attachments as: .zip

Change History (8)

#1 @AaronCampbell
16 years ago

  • Keywords has-patch needs-testing added

The patch should be completely backward compatible, and would allow a plugin to pull the current user data and compare it to the old.

#2 @AaronCampbell
16 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.

#3 @ryan
16 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [8969]) Pass old user data to profile_update action. Props AaronCampbell. fixes #7784

#4 follow-up: @crazycoders
13 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"


call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));


call_user_func_array($the_['function'], $args);

Instead of slicing the args array from 0 to X arguments.

Last edited 10 years ago by SergeyBiryukov (previous) (diff)

#5 @SergeyBiryukov
13 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 @aaroncampbell
13 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.

Last edited 13 years ago by aaroncampbell (previous) (diff)

#7 @nacin
13 years ago

With regards to why we don't just pass $args: #14671.

Note: See TracTickets for help on using tickets.