这是一个基于他人作品的修改版本,here. 如果用户的电子邮件字段已更改,此实例将发送电子邮件。将“user\\u email”与您喜欢的任何用户元交换。
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 protected]\';//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
}
}