Created
October 14, 2011 08:40
-
-
Save NateJacobs/1286583 to your computer and use it in GitHub Desktop.
WordPress Function: Every time a user updates his/her profile an email is sent to the site administrator.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Updated User Profile Notification | |
* | |
* Every time a user updates his/her profile an email is sent | |
* to the site administrator. | |
* | |
* @author Nate Jacobs | |
* @link https://gist.github.com/1286583 | |
*/ | |
add_action( 'profile_update', 'ngtj_updated_user_profile_notify', 10, 2 ); | |
function ngtj_updated_user_profile_notify( $user_id, $old_user_data ) | |
{ | |
// get the user data into an object | |
$user = get_userdata( $user_id ); | |
// get the site administrator's email address | |
$admin_email = get_option( 'admin_email' ); | |
// the email body | |
$message = sprintf( __( 'This user has updated their profile on your site: %s' ), get_option('blogname') ) . "\r\n\r\n"; | |
$message .= sprintf( __( 'Display Name: %s' ), $user->display_name ). "\r\n\r\n"; | |
$message .= sprintf( __( 'Username: %s' ), $user->user_login ). "\r\n\r\n"; | |
$message .= sprintf( __( 'Old Email: %s' ), $old_user_data->user_email ). "\r\n\r\n"; | |
$message .= sprintf( __( 'Email: %s' ), $user->user_email ); | |
// send the email | |
wp_mail( $admin_email, sprintf( __( '[%s] User Updated a Profile' ), get_option('blogname') ), $message ); | |
} | |
?> |
Can you please tell me how to use this?
looks like as of WP 3.4 this action is depreciated, and you should use
http://codex.wordpress.org/edit_user_profile_update
http://codex.wordpress.org/Plugin_API/Action_Reference/profile_update
I'm looking for something like this, but this only say that somebody change the profile, but don't say whats fields changes. Can anybody help me?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your welcome Jeff. Glad it helped you out.