Php 参数太少,无法在电子邮件挂钩中运行

Php 参数太少,无法在电子邮件挂钩中运行,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我正在用PHP创建一个函数,我想在其中传递三个参数,如下所示: function lnz_wc_emails_memberreceipients($headers, $object, $order) { $company = $order->billing_company; $emailreturn = array ( 'Robin' => "weiltest@weiltest.com", 'Other' => "beistest@beistest.com,

我正在用PHP创建一个函数,我想在其中传递三个参数,如下所示:

function lnz_wc_emails_memberreceipients($headers, $object, $order) {

$company = $order->billing_company;

$emailreturn = array (
    'Robin' => "weiltest@weiltest.com",
    'Other' => "beistest@beistest.com, beistest2@beistest.com"
);

$headers = array();
$headers[] = 'Bcc: your name '.$emailreturn[$company];
$headers[] = 'Content-Type: text/html';
return $headers;

}
add_filter( 'woocommerce_email_headers', 'lnz_wc_emails_memberreceipients', 10, 2);
然而,当我尝试这样做时,我得到一个错误,这表明我的函数要求3个参数,但只传递了2个

Fatal error: Uncaught ArgumentCountError: Too few arguments to function lnz_wc_emails_memberreceipients(), 2 passed in /home/benefacto/public_html/dev3/wp-includes/class-wp-hook.php on line 300 and exactly 3 expected in /home/benefacto/public_html/dev3/wp-content/plugins/bnfo-custom-emails/bnfo-custom-emails.php:17 Stack trace: #0 /home/benefacto/public_html/dev3/wp-includes/class-wp-hook.php(300): lnz_wc_emails_memberreceipients('Content-Type: t...', 'customer_comple...') #1 /home/benefacto/public_html/dev3/wp-includes/plugin.php(203): WP_Hook->apply_filters('Content-Type: t...', Array) #2 /home/benefacto/public_html/dev3/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php(287): apply_filters('woocommerce_ema...', 'Content-Type: t...', 'customer_comple...', Object(WC_Order)) #3 /home/benefacto/public_html/dev3/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-completed-order.php(75): WC_Email->get_headers() #4 /home/benefacto/public_html/dev3/wp-includes/class-wp-hook.php(298): WC_Email in /home/benefacto/public_html/dev3/wp-content/plugins/bnfo-custom-emails/bnfo-custom-emails.php on line 17
如果我删除$object或$order,它就可以正常工作!但如果我尝试将两者都包括在内,它就会产生抖动

我能做些什么来通过这三个考试吗?非常感谢您的任何想法。

替换

add_filter( 'woocommerce_email_headers', 'lnz_wc_emails_memberreceipients', 10, 2);


它接受过滤器的3个参数
woocommerce\u email\u headers

谢谢。工作起来很有魅力。
add_filter( 'woocommerce_email_headers', 'lnz_wc_emails_memberreceipients', 10, 3);