还向登录用户发送管理员新订单电子邮件

时间:2019-03-20 作者:BarrieO

我需要能够发送admin email for a new order 同时发送至电子邮件地址linked to the current logged in user.

这是必需的,因为1 account 是为了different people (赠送礼物的人),但最初创建的帐户仍链接到原始用户电子邮件地址(来自家长)。

这样,当父母收到新礼物时,他们会通过电子邮件通知他们。

我似乎找不到解决办法。我从Adding a second email address to a completed order in WooCommerce, 但现在我想动态添加用户的电子邮件地址。

知道我做错了什么吗?

/* SEND ADMIN E-MAIL TO LOGGED IN USER */
/* --- */
add_filter( \'woocommerce_email_recipient_new_order\', \'your_email_recipient_filter_function\', 10, 2);

/* Add parents e-mail address to new order admin mail */
function your_email_recipient_filter_function($recipient, $object) {
    $user_info = get_userdata($order->user_id);
    $recipient = $recipient . \', \' . $user_info->user_email;
    return $recipient;
}

1 个回复
最合适的回答,由SO网友:tmdesigned 整理而成

除了变量名不匹配之外,您所拥有的一切都是有意义的。在函数定义和函数代码中有$对象,您试图使用$顺序。

已调整:

/* SEND ADMIN E-MAIL TO LOGGED IN USER */
/* --- */
add_filter( \'woocommerce_email_recipient_new_order\', \'your_email_recipient_filter_function\', 10, 2);

/* Add parents e-mail address to new order admin mail */
function your_email_recipient_filter_function($recipient, $order) {
    $user_info = get_userdata($order->user_id);
    $recipient = $recipient . \', \' . $user_info->user_email;
    return $recipient;
}

相关推荐

使用wp_new_user_tification_email筛选器时获取密码密钥

我正在尝试自定义发送给新注册用户的电子邮件。我使用wp_new_user_notification_email 过滤插件,设置主题和消息就可以了。然而I would like to send the link to reset the user\'s password the same way the normal WP notification email does. 从我在wp_new_user_notification 函数,密码密钥在存储到数据库之前经过哈希处理。然后在url中使用此密钥重置密码。