X

Send email notification when profile updates

I got a few emails asking about sending an email when a user simply updates the profile. Well here it is, adding this snippet to the functions.php of your wordpress theme will send an email notification to the user when the user profile updates.



Code Snippet:


function user_profile_update( $user_id ) {
$site_url = get_bloginfo('wpurl');
$user_info = get_userdata( $user_id );
$to = $user_info->user_email;
$subject = "Profile Updated: ".$site_url."";
$message = "Hello " .$user_info->display_name . "\nYour profile has been updated!\n\nThank you for visiting\n ".$site_url."";
wp_mail( $to, $subject, $message);
}
add_action( 'profile_update', 'user_profile_update', 10, 2);

Comments  Leave a Reply

  1. Hello please i am new to wordpress,i want to set up multiple users which i have been able to do but also i want users to be notified via mail when new posts are added or updates are added.I read up your wordpress snippet on adding the codes u have above to function.php i cant find this function.php anywhere on my C drive.Please help out thanks

  2. its workin perfectly. but mail is showing to spam folder

    🙁

    1. Not much can be down about that, I would think it has to do with spam settings.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!