是否可以修改在WordPress网站上注册帐户时发送给用户的激活电子邮件的内容?
我希望更改电子邮件的主题和正文,以便根据我的网站信息阅读更多内容 .
我试图将以下内容添加到mu-plugins中的自定义插件中,但它似乎根本没有任何影响:
<?php
/*
Plugin Name: Disable Username and Password Notification
Description: Disables the Username and Password email
*/
// Start changing email body
function myprefix_change_activation_email_body ($old_body, $domain, $path, $title, $user, $user_email, $key, $meta) {
$my_message = "Hi! This is my new email! ";
$my_message .= "Your site {$title} is almost ready. We probably also want to include the activation key: {$key} ";
$my_message .= "Activate your site here : http://{$domain}{$path}wp-activate.php?key=$key";
// ... other stuff
return $my_message;
}
add_filter('wpmu_signup_blog_notification_email', 'myprefix_change_activation_email_body', 10, 8);
// End changing email body
// Start changing email subject
function myprefix_change_activation_email_subject ($old_subject, $domain, $path, $title, $user, $user_email, $key, $meta) {
$my_subject = "Hi! You just registered on my site!";
return $my_subject;
}
add_filter('wpmu_signup_blog_notification_subject', 'myprefix_change_activation_email_subject', 10, 8);
// End changing email subject
据我所知,问题是所使用的过滤器很可能是我的网站没有的MultiSite设置 . 它只是一个标准的WordPress网站 .
干杯
1 回答
你正在寻找的功能是wp_new_user_notification它是一个pluggable function . 可插入功能是允许您覆盖Wordpress核心功能的功能 .
您可以简单地覆盖:
在mu-plugins文件夹中创建一个文件,你可以调用你想要的任何东西,但你应该给出一个有意义的名字,比如custom-new-user-notification.php
复制默认函数并将其包装在if语句中,检查函数是否为最佳实践,否则会产生错误)
更改消息和主题(或任何您想要更改的内容)
例: