WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to send the updated/added values from profile, when a member/user updates his/hers data, to the admin of the site or another emailadress?

Can this be the first step?

/* do something when user edits profile */
add_action('personal_options_update', 'notify_admin_on_update');
function notify_admin_on_update(){
  // send a mail with the updated values to admin@mysite.com

What is best pracice to send emails from within WordPress?

share|improve this question
up vote 8 down vote accepted

you got the first part right about using personal_options_update but to be on the safe side add edit_user_profile_update also. and as for sending emails within WordPress the best way would be to use wp_mail, So something like this:

add_action( 'personal_options_update', 'notify_admin_on_update' );
add_action( 'edit_user_profile_update','notify_admin_on_update');
function notify_admin_on_update(){
    global $current_user;

    if (!current_user_can( 'administrator' )){// avoid sending emails when admin is updating user profiles
        $to = 'admin@email.com';
        $subject = 'user updated profile';
        $message = "the user : " .$current_user->display_name . " has updated his profile with:\n";
        foreach($_POST as $key => $value){
            $message .= $key . ": ". $value ."\n";
        wp_mail( $to, $subject, $message);
share|improve this answer
Your if statement will assign 1 as the current user id, thus making anybody who updates a profile temporarily an administrator. Instead of using user id numbers, it makes more senese to check for permsissions: if( !current_user_can( 'administrator' ) ) – John P Bloch Mar 16 '11 at 14:19
thanks for the correction i updated the code – Bainternet Mar 16 '11 at 15:08
Thanks, Bainternet and John P Bloch! I used: if ($current_user->ID != 1){ – Fredag Mar 16 '11 at 15:43
I have a second question to this issue: – Fredag Jun 16 '11 at 9:02
I have a second question to this issue: The above suggestions works well but I want to only show/email the data that was updated, not all of the users data. And is it possible to email the data when a specific field has been updated. – Fredag Jun 16 '11 at 9:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.