profile_update not supplying old data
Question
According to the WP documentation, the hook ‘profile_update’ fires after a profile is updated and provides the user id and the user object with the data BEFORE the update (I need both):
$old_user_data (WP_User) Object containing user’s data prior to update.
However, when I try to access this, I get the new data and not the old. Here’s the code:
add_action( 'profile_update', 'mgf_profile_update', 10, 2 );
function mgf_profile_update( $user_id, $old_user_data ) {
$member = get_userdata($user_id);
echo 'old town ' . $old_user_data->country . '<br>';
echo 'new town ' . $member->country . '<br>';
die;
}
In the test I made, a user’s country (a custom field) was set to ‘Italy’ and I updated this to ‘Italia’. The result was this:
old town Italia
new town Italia
Any ideas as to what I am doing wrong?
0
2 years
2020-12-25T08:10:23-05:00
2020-12-25T08:10:23-05:00 0 Answers
7 views
0
Leave an answer