我之前问过,当用户/成员更改其个人资料数据时,如何自动向管理员发送电子邮件。得到了一些很好的答案。Send automatic mail to Admin when user/member changes/adds profile
接下来,我只想发送/通过电子邮件发送更新/添加的数据(profiledata)。
我之前问过,当用户/成员更改其个人资料数据时,如何自动向管理员发送电子邮件。得到了一些很好的答案。Send automatic mail to Admin when user/member changes/adds profile
接下来,我只想发送/通过电子邮件发送更新/添加的数据(profiledata)。
因此,正如Bainternet所指出的,您需要将新字段值与编辑之前的值进行比较。本质上,您需要为概要文件字段构建版本控制。您需要添加一个数据库表来存储此信息,使用the $wpdb
object 写,读。
基本上,开personal_options_update
和edit_user_profile_update
您将像前面的回答一样收集数据,但也将其与存储上一次保存中存在的内容的表进行比较。只有在不匹配的情况下,才会发送特定字段的数据。
这是一个基于他人作品的修改版本,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@example.com\';//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
}
}
我在本地主机上安装了WordPress。直到今天,一切都很顺利。但今天当我进去的时候http://localhost/wp-admin 在访问管理面板的url中,它重定向回主页。我无法访问管理面板。以前从未发生过,每当我尝试访问管理面板时,它都会发生。请大家帮帮我。。。。非常感谢。