Title: [wp_update_user hook]
Last modified: August 21, 2016

---

# [wp_update_user hook]

 *  [lorenzo](https://wordpress.org/support/users/psycolor/)
 * (@psycolor)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/wp_update_user-hook/)
 * hi folks,
 * i am trying to create a hook to add to my theme functions.php file which sends
   an email notification to the admin when a user update their profile.
 * as you can see below i have managed to get the work half done (i.e. prepare the
   message and pass the details of the updates), however i would like to pass also
   the details *before the update* (in my case the old_user_data).
 * the code below passes the new info. can anyone suggest how to pick up the details
   before the update is actually performed?
 *     ```
       function user_profile_update($userid, $old_user_data) {
       	$userdata = get_userdata($userid);
       	$message = "A user profile has been updated\n\n";
       	foreach($_POST as $key => $value){
                   $message .= $key . ": ". $value ."\n";
               }
       	//$message .= print_r($userdata,true);
       	$message .= "old data\n\n";
       	$message .= print_r($old_user_data,true);
       	@wp_mail(get_option('admin_email'), 'User Profile Update', $message);
       }
       add_action('profile_update','user_profile_update');
       ```
   
 * thanks
 * lorenzo

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [sozot](https://wordpress.org/support/users/sozot/)
 * (@sozot)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/wp_update_user-hook/#post-3680937)
 * $old_user_data has the WP_User object and it looks like you’re already appending
   that to the $message. It looks to me like you’re already including the old and
   new data.
 *  Thread Starter [lorenzo](https://wordpress.org/support/users/psycolor/)
 * (@psycolor)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/wp_update_user-hook/#post-3680971)
 * hi Andy,
 * thanks for the reply. yes, that would be the theory (or what i thought i was 
   doing with this function), but the problem is that $old_user_data seems to be
   empty and i don’t know how to ‘catch’ the data before the update is carried out.
 * the codex docs are not very clear and i should also say that i’m not a programmer,
   which makes this a bit of a struggle.
    any suggestion will be very welcome!
 * lorenzo
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/wp_update_user-hook/#post-3681023)
 * Modify add_action() like so:
    `add_action('profile_update','user_profile_update',
   10, 2);`
 * You must supply the ‘2’ parameter to get both parameters passed to your callback
   function. The ’10’ is the default priority value, which should be fine as is,
   it’s mainly there so the ‘2’ can be passed.
 *  Thread Starter [lorenzo](https://wordpress.org/support/users/psycolor/)
 * (@psycolor)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/wp_update_user-hook/#post-3681040)
 * this is brilliant thanks, adding the parameter did the trick, but i have absolutely
   no idea why. if you have any link explaining things in more detail i’d love to
   learn more (and hopefully it will be helpful for other reading the thread in 
   the future.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/wp_update_user-hook/#post-3681057)
 * [Function_Reference/add_filter](http://codex.wordpress.org/Function_Reference/add_filter)
   has a slightly better explanation, the concept applies equally to add_action().
   Unfortunately, it’s a less than satisfactory explanation IMO. If it’s still not
   making sense, if you can ask a specific question here, I will attempt to explain
   further.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘[wp_update_user hook]’ is closed to new replies.

## Tags

 * [admin notification](https://wordpress.org/support/topic-tag/admin-notification/)
 * [profile update](https://wordpress.org/support/topic-tag/profile-update/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 5 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/wp_update_user-hook/#post-3681057)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
