下面的函数没有重写wp\\u mail()那么令人讨厌,它允许您在应该禁用电子邮件时添加额外的逻辑
function childtheme_no_emails( &$phpmailer ) {
// Empty out the values that may be set
$phpmailer->ClearAllRecipients();
$phpmailer->ClearAttachments();
$phpmailer->ClearCustomHeaders();
$phpmailer->ClearReplyTos();
}
add_action( \'phpmailer_init\', \'childtheme_no_emails\', 99, 1 );