WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 2 years ago

Last modified 6 weeks ago

#7784 closed defect (bug) (fixed)

Pass old user data to profile_update action

Reported by: AaronCampbell 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)

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

Download all attachments as: .zip

Change History (8)

comment:1 AaronCampbell6 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.

AaronCampbell6 years ago

comment:2 AaronCampbell6 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.

comment:3 ryan6 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

comment:4 follow-up: crazycoders2 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.

Last edited 6 weeks ago by SergeyBiryukov (previous) (diff)

comment:5 SergeyBiryukov2 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.

comment:6 in reply to: ↑ 4 aaroncampbell2 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 );
Version 0, edited 2 years ago by aaroncampbell (next)

comment:7 nacin2 years ago

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

Note: See TracTickets for help on using tickets.