Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have previously asked about How to automatically send email to Admin when a user/member changes his/hers profile data. And got some very good answers. Send automatic mail to Admin when user/member changes/adds profile.

Now a follow up: I only want to send/email the data (profiledata) that was updated/added.

share|improve this question
    
You might want to reward the answer to the previous question. Folks are less likely to help someone who doesn't accept answers. –  two7s_clash Jun 16 '11 at 19:51
    
Ok. So, two7s_clash tell me how to do that other than expressing my gratitude which I have done. To up-vote the excellent answer more required 15 "points" which I don't have. –  Fredag Jun 17 '11 at 12:20
    
You don't up vote it, you accept it as correct by checking the check. –  two7s_clash Jun 17 '11 at 14:56
    
@two7s_clash: Thanks. Checked! And now green... And I have read the faq! –  Fredag Jun 17 '11 at 15:09
add comment

2 Answers

up vote -1 down vote accepted

So, as Bainternet notes, you would need to compare the new field value to what it was right before the edit. In essence, you will need to build in version control for the profile fields. You will need to add a database table to store this info, using the the $wpdb object to write, and read from it.

Basically, on personal_options_update and edit_user_profile_update you will glean the data as in the previous answer, but then also compare it to your table storing the what existed in the previous save. You'll only send a particular field's data if there is mismatch.

share|improve this answer
    
I was hoping for an easier solution but will do some experiments with this. Thanks two7s_clash and Bainternet! –  Fredag Jun 20 '11 at 9:07
add comment

Here's a modified version building on the work from others, here. This instance sends an email if the user's email field has been changed. Swap 'user_email' with whatever user meta you like.

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;
get_currentuserinfo();

if (!current_user_can( 'administrator' )){// avoid sending emails when admin is updating user profiles
    $to = 'email@example.com';//change this email to whatever
    $subject = 'A user has updated their profile';//sent email subject field
    $message = "The user : " .$current_user->display_name . " has updated their email to: " .$current_user->user_email."";
    wp_mail( $to, $subject, $message);//the code that sends the message
}
}
share|improve this answer
add comment

Your Answer

 
discard

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.