【问题标题】:WordPress: How can change customise user emails messageWordPress:如何更改自定义用户电子邮件消息
【发布时间】:2014-11-25 21:33:29
【问题描述】:

我需要更改所有消息:-

新用户活跃。 新用户欢迎电子邮件。 密码提醒电子邮件。

所以我需要更改所有Customise User Emails

【问题讨论】:

    标签: wordpress email


    【解决方案1】:

    Wordpress 中的电子邮件功能是可插入的,这意味着您可以用自己的方式覆盖它们。

    如果您是初学者并且想快速解决这个问题,我相信插件是可行的方法,我发现这个看起来不错 - https://wordpress.org/plugins/wp-better-emails/

    EDIT - 上面的插件好像没有解决问题,实际上好像没有插件可以一次编辑所有系统生成的插件。

    本教程似乎是要走的路 - http://www.smashingmagazine.com/2011/10/25/create-perfect-emails-wordpress-website/

    基本上我们需要做的是重新定义函数,如上所述:

    有问题的函数称为 wp_new_user_notification()。到 修改它,我们需要做的就是创建一个同名的函数。 由于 WordPress 调用可插入函数的方法,有 不会有任何冲突,即使您正在创建一个函数 同名。下面是我写的函数。看说明 并在下面进一步预览。

    例如,要编辑用户注册电子邮件,您需要编辑函数 wp_new_user_notification()。为此,只需将以下代码添加到您的functions.php:

    function wp_new_user_notification($user_id, $plaintext_pass) {
        $user = new WP_User($user_id);
    
        $user_login = stripslashes($user->user_login);
        $user_email = stripslashes($user->user_email);
    
        $email_subject = "Welcome to MyAwesomeSite ".$user_login."!";
    
        ob_start();
    
        include("email_header.php");
    
        ?>
    
        <p>A very special welcome to you, <?php echo $user_login ?>. Thank you for joining MyAwesomeSite.com!</p>
    
        <p>
            Your password is <strong style="color:orange"><?php echo $plaintext_pass ?></strong> <br>
            Please keep it secret and keep it safe!
        </p>
    
        <p>
            We hope you enjoy your stay at MyAwesomeSite.com. If you have any problems, questions, opinions, praise, 
            comments, suggestions, please feel free to contact us at any time
        </p>
    
    
        <?php
        include("email_footer.php");
    
        $message = ob_get_contents();
        ob_end_clean();
    
        wp_mail($user_email, $email_subject, $message);
    

    【讨论】:

    • 我尝试使用这个插件 - https://wordpress.org/plugins/wp-better-emails/ 但我不明白这不是我的需要,第二个链接在 WordPress 中是新的,我需要它的好插件
    • @KotshMan 我已经编辑了原始答案,现在它包含帮助您整理解决方案的代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-25
    相关资源
    最近更新 更多