更改管理员更改密码/电子邮件地址时发送的电子邮件模板

问题描述:

我们的许多用户忘记了我们网站的电子邮件地址详细信息和密码,他们要求我帮助他们登录.当我更改他们的密码/电子邮件地址时,他们会收到如下电子邮件:

Lots of our users forgot e-mail adress details and passwords for our website and they are asking me to help them log in. When I change their password/e-mail adress they receive an e-mail message like this:

块引用

From: WordPress <wordpress@example.com>
To: username@example.com
Subject: [WordPress] Password Changed

Hi username,

This notice confirms that your password was changed on WordPress.

If you did not change your password, please contact the Site Administrator at admin@example.com

This email has been sent to username@example.com

Regards,
All at WordPress
http://example.com/

我想自定义发送的消息,但此模板没有出现在/wp-admin/Emails 选项卡中,就像用户自己更改密码时发送的消息一样.请帮帮我好吗?

I'd like to customize the message which is sent, but this template doesn't appear in the /wp-admin/Emails tab, like the message which is sent when users change their password themselves. Could you help me, please?

正确的做法是,遵循 Wordpress 指南,使用 add_filer 作为 password_change_email 钩子.不要按照上面的建议更改 wp-includes 文件,因为它会被未来的 WP 版本覆盖.

The correct way to do it, following Wordpress guidelines is by using add_filer for the password_change_email hook. Do not change wp-includes files as recommended above, as it will be overrun by future WP releases.

您可以在主题的functions.php 文件或插件中添加过滤器.

you can add the filter in your functions.php file of your theme, or in a plugin.

它应该是这样的:

function my_theme_password_change_email($pass_change_email, $user, $userdata){
   //do your changes here
}
add_filter( "password_change_email", "my_theme_password_change_email",10,3 )