首页 > 解决方案 > 发送邮件前使用 file_put_contents 打印

问题描述

我使用 'wpcf7_posted_data' 挂钩在 Wordpress 中的联系表格 7 后更改了一些数据。我想打印 $array 的内容,所以我尝试使用 file_put_contents() 将其打印到文件中,但是当我尝试发送邮件时,它卡住了,什么也没有……(也没有文件)

如何得到它?

谢谢


add_filter('wpcf7_posted_data', 'action_wpcf7_posted_data', 10, 1);
function action_wpcf7_posted_data($array)
{

    $ses = get_field('date');
    $sesCount = count($ses["body"]);
    $a = "";
    for ($i = 0; $i <= $sesCount; $i++) {
        if ($ses[$i][1]["c"] == $array['upcoming-gigs']) {
            $array['bla'] = strval($ses[$i][0]["c"]);
        }
    }
    file_put_contents('file.txt', var_export($array));

    $array['Session'] = $array['upcoming-gigs'];
    unset($array['upcoming-gigs']);

    return $array;
}


标签: phpwordpressadvanced-custom-fields

解决方案


将此行从更改file_put_contents('file.txt', var_export($array));file_put_contents('file.txt', var_export($array, true));


推荐阅读