Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
WordPress Function: Every time a user updates his/her profile an email is sent to the site administrator.
<?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 );
}
?>
@jkbennett

This comment has been minimized.

Show comment Hide comment
@jkbennett

jkbennett Aug 9, 2012

Thanks Nate. Worked great for my Wordpress site http://desktopanywhere.com and I use it in conjunction with the New Fields I added via:

http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields

Add to that the amr users plugin and with your code above, just adding a line for each new field via $message, really made managing my site so much better.

Excellent work and thanks again,

Jeff

Thanks Nate. Worked great for my Wordpress site http://desktopanywhere.com and I use it in conjunction with the New Fields I added via:

http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields

Add to that the amr users plugin and with your code above, just adding a line for each new field via $message, really made managing my site so much better.

Excellent work and thanks again,

Jeff

@NateJacobs

This comment has been minimized.

Show comment Hide comment
@NateJacobs

NateJacobs Aug 10, 2012

Your welcome Jeff. Glad it helped you out.

Owner

NateJacobs commented Aug 10, 2012

Your welcome Jeff. Glad it helped you out.

@abis221

This comment has been minimized.

Show comment Hide comment
@abis221

abis221 Sep 23, 2012

Can you please tell me how to use this?

abis221 commented Sep 23, 2012

Can you please tell me how to use this?

@blotto

This comment has been minimized.

Show comment Hide comment
@blotto

blotto Feb 4, 2013

@Ulises2010

This comment has been minimized.

Show comment Hide comment
@Ulises2010

Ulises2010 Jan 8, 2014

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?

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