编辑WordPress“邮件地址更改通知”的电子邮件文本

5
如果我作为管理员登录WordPress并更改另一个用户的电子邮件地址,系统将自动向该用户发送以下电子邮件:

您好 [用户名],此通知确认您在 [网站] 上更改了您的电子邮件地址。如果您没有更改您的电子邮件,请联系站点管理员: [管理员电子邮件]。 此电子邮件已发送至 [用户电子邮箱]。敬礼,[网站][网站URL]

是否有办法编辑此消息以显示其他内容?
2个回答

7
你可以使用email_change_email过滤器。在WordPress Codex中了解有关此过滤器的更多信息。也可以在hookr.io上了解相关信息。

在这里了解如何添加过滤器。

    /* Filter Email Change Email Text */

    function so43532474_custom_change_email_address_change( $email_change, $user, $userdata ) {

        $new_message_txt = __( 'Change the text here, use ###USERNAME###, ###ADMIN_EMAIL###, ###EMAIL###, ###SITENAME###, ###SITEURL### tags.' );

        $email_change[ 'message' ] = $new_message_txt;

        return $email_change;

    }
    add_filter( 'email_change_email', 'so43532474_custom_change_email_address_change', 10, 3 );

更多详细信息请参考此处:https://developer.wordpress.org/reference/hooks/email_change_email/ - Sam G

0

只需从根目录中的/wp-includes/user.php第2064行进行编辑,或搜索'Hi ###USERNAME###,,您将找到以下消息正文,您可以根据自己的喜好进行自定义。

$email_change_text = __(
    'Hi ###USERNAME###,

This notice confirms that your email address on ###SITENAME### was changed to ###NEW_EMAIL###.

If you did not change your email, please contact the Site Administrator at
###ADMIN_EMAIL###

This email has been sent to ###EMAIL###

Regards,
All at ###SITENAME###
###SITEURL###'
                     );


编辑wp核心文件是一个非常糟糕的想法。下次更新时,所有的编辑都将丢失。更好的解决方案是按照Christina提到的那样创建一个过滤器。 - gael

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接