我正在使用我们网站上的联系表7,以便人们预订活动。预订后,他们将收到一份ICS文件和一张PDF格式的门票。我正在使用wpcf7_before_send_mail
钩子更改用户预订后发送给他们的电子邮件。
一切都很好,我可以添加一个附件,但只要我添加多个附件,它就不起作用了。
我还确认,我的代码中没有错误。
Here\'s my code:
add_attachments_before_send($WPCF7_ContactForm)
{
$wpcf = WPCF7_ContactForm::get_current();
$submission = WPCF7_Submission::get_instance();
if ($submission)
{
// This generates the ICS file and returns as a file path
$ics = generateICS( $pID, $dts, $dte, $venue );
// This generates the event ticket file and also returns as a file path
$ticket = generate_event_ticket( $pID, $dts, $venue, $name );
$mail = $wpcf->prop(\'mail_2\');
if ($ics)
{
$mail[\'attachments\'][] = $ics;
}
if ($ticket)
{
$mail[\'attachments\'][] = $ticket;
}
$wpcf->set_properties(array(
\'mail_2\' => $mail
));
return $wpcf;
}
}
add_action("wpcf7_before_send_mail", "add_attachments_before_send");
我也尝试过更换这个
$mail[\'attachments\'][] = $ics;
具有
$mail[\'attachments\'] .= $ics;
将其用作字符串,但也不起作用。