有些朋友希望在用户的个人资料更新时,发送邮件通知用户,那么,你可以将下面的代码添加到主题的 functions.php 文件:
/**
* WordPress 用户的<a href="https://www.wpdaxue.com/tag/%e4%b8%aa%e4%ba%ba%e8%b5%84%e6%96%99" title="查看与【个人资料】相关的文章" target="_blank" rel="noopener">个人资料</a>更新时发送邮件通知
* https://www.wpdaxue.com/send-email-notification-when-profile-updates.html
*/
function user_profile_update( $user_id ) {
$site_url = get_bloginfo('wpurl');
$user_info = get_userdata( $user_id );
$to = $user_info->user_email;
$subject = "个人资料已更新: ".$site_url."";
$message = "您好 " .$user_info->display_name . "\n您的个人资料已更新!\n\n感谢您访问\n ".$site_url."";
wp_mail( $to, $subject, $message);
}
add_action( 'profile_update', 'user_profile_update', 10, 2); |
/**
* WordPress 用户的<a href="https://www.wpdaxue.com/tag/%e4%b8%aa%e4%ba%ba%e8%b5%84%e6%96%99" title="查看与【个人资料】相关的文章" target="_blank" rel="noopener">个人资料</a>更新时发送邮件通知
* https://www.wpdaxue.com/send-email-notification-when-profile-updates.html
*/
function user_profile_update( $user_id ) {
$site_url = get_bloginfo('wpurl');
$user_info = get_userdata( $user_id );
$to = $user_info->user_email;
$subject = "个人资料已更新: ".$site_url."";
$message = "您好 " .$user_info->display_name . "\n您的个人资料已更新!\n\n感谢您访问\n ".$site_url."";
wp_mail( $to, $subject, $message);
}
add_action( 'profile_update', 'user_profile_update', 10, 2);
如果你希望用户的个人资料更新时,发送邮件通知管理员,可以使用下面的代码:
/**
* WordPress 用户的个人资料更新时发送邮件通知
* https://www.wpdaxue.com/send-email-notification-when-profile-updates.html
*/
function user_profile_update_email_admin( $user_id ) {
$site_url = get_bloginfo('wpurl');
$user_info = get_userdata( $user_id );
$to = get_option( 'admin_email' );
$subject = $user_info->display_name." 的个人资料已更新";
$message = "您好,管理员。用户 " .$user_info->display_name . " 的个人资料已更新!\n\n访问\n ".$site_url."";
wp_mail( $to, $subject, $message);
}
add_action( 'profile_update', 'user_profile_update_email_admin', 10, 2); |
/**
* WordPress 用户的个人资料更新时发送邮件通知
* https://www.wpdaxue.com/send-email-notification-when-profile-updates.html
*/
function user_profile_update_email_admin( $user_id ) {
$site_url = get_bloginfo('wpurl');
$user_info = get_userdata( $user_id );
$to = get_option( 'admin_email' );
$subject = $user_info->display_name." 的个人资料已更新";
$message = "您好,管理员。用户 " .$user_info->display_name . " 的个人资料已更新!\n\n访问\n ".$site_url."";
wp_mail( $to, $subject, $message);
}
add_action( 'profile_update', 'user_profile_update_email_admin', 10, 2);
来源:
https://www.wpdaxue.com/send-email-notification-when-profile-updates.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_33159.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57