【发布时间】:2022-11-10 18:04:29
【问题描述】:
我需要禁用向管理员发送新帐户的默认电子邮件。
我查看了 unhook_those_pesky_emails 代码,但没有看到新帐户的代码
代码的 sn-p 可能开始像
remove_action( 'woocommerce_created_customer_notification',
【问题讨论】:
-
请提供足够的代码,以便其他人可以更好地理解或重现该问题。
标签: hook-woocommerce
我需要禁用向管理员发送新帐户的默认电子邮件。
我查看了 unhook_those_pesky_emails 代码,但没有看到新帐户的代码
代码的 sn-p 可能开始像
remove_action( 'woocommerce_created_customer_notification',
【问题讨论】:
标签: hook-woocommerce
对于展望未来的人来说,这可能是您需要的代码:
<?php
//Disable 'new user' notification for the site admin
function woo_disable_new_user_notifications() {
//Remove original emails
remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 );
//Add new function to take over email creation
add_action( 'register_new_user', 'woo_send_new_user_notifications' );
add_action( 'edit_user_created_user', 'woo_send_new_user_notifications', 10, 2 );
}
function woo_send_new_user_notifications( $user_id, $notify = 'user' ) {
if ( empty($notify) || $notify == 'admin' ) {
return;
}elseif( $notify == 'both' ){
//Only send the new user an email, not the admin
$notify = 'user';
}
woo_send_new_user_notifications( $user_id, $notify );
}
add_action( 'init', 'woo_disable_new_user_notifications' );
这将禁用向站点管理员发送有关新用户注册的 WordPress 通知。
【讨论】: