Make WordPress Core

Opened 11 years ago

Closed 4 years ago

Last modified 4 years ago

#27377 closed enhancement (worksforme)

profile_update action with old_user_data should include the additional_user_keys data?

Reported by: joostdekeijzer's profile joostdekeijzer Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: Users Keywords: close
Focuses: administration Cc:

Description

Currently, when a users profile is updated, the profile_update action is called with the $user_id and $old_user_data as parameters.

$old_user_data is an object containing only the basic WP_User fields, but none of the additional user keys (first_name, last_name, etc. are not part of this object)

It would be nice if $old_user_data actually contained all (WordPress defined) userfields.

That way, one could for example write a plugin to email changes to an administrator, but only when there actually was a change!

Relevant code is in wp-includes/user.php, the wp_insert_user() method.

Change History (5)

#1 @SergeyBiryukov
11 years ago

  • Version changed from trunk to 2.7

Related: #7784

#2 @chriscct7
9 years ago

  • Keywords needs-patch added

#3 @donmhico
4 years ago

  • Keywords close added; needs-patch removed

This ticket has been opened 7 years ago but looking at the code now (5.8) and even here [8969]. $old_user_data = get_userdata( $ID ); And get_user_data() returns WP User. So it's possible to get the additional user fields like so

<?php
$old_user_data = get_userdata( $ID );
$old_user_data->first_name;
$old_user_data->last_name

So I don't think any changes are needed. Closing this ticket for now. Feel free to open if I misunderstood anything.

#4 @johnbillion
4 years ago

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

Confirmed. These fields aren't public properties on the WP_User object in $old_user_data but they are returned if you request the properties.

Ref: https://github.com/WordPress/wordpress-develop/blob/30ff995eb0aa2660ef4b08b9e3c5f7b0126c702b/src/wp-includes/class-wp-user.php#L15-L36

#5 @joostdekeijzer
4 years ago

Agreed, lots of things changed since opening this ticket. Thanks for the feedback.

Note: See TracTickets for help on using tickets.