Send email notifications to admin when user updates their profile
-
I’ve been looking for a function to send admin an email when a use updates their profileand have used the below which works fine, however admin is also getting this notification when a customer places an order. Does anyone know how I could exclude the email from being fired from the checkout process?
Thanks
Wag// send email notification to admin on profile updates
function my_admin_notification_profile_update($userid) {
if(did_action(‘profile_update’) === 1) {
// this code only runs the first time the “profile_update” hook is fired
if (!current_user_can( ‘administrator’ )){// avoid sending emails when admin is updating user profiles
$userdata = get_userdata($userid);
$current_user = wp_get_current_user();
$message = “The customer : ” .$current_user->company. ” message here:\n\n”;
foreach($_POST as $key => $value){
$message .= $key . “: “. $value .”\n”;
}
@wp_mail(get_option(‘admin_email’), ‘Customer Profile Update’, $message);
}
}}
add_action(‘profile_update’,’my_admin_notification_profile_update’);
- The topic ‘Send email notifications to admin when user updates their profile’ is closed to new replies.