Search code examples
phpwordpressadvanced-custom-fields

Print with file_put_contents before sending a mail


I change some data after a contact form 7 in a Wordpress using 'wpcf7_posted_data' hook. I would like to print the content of $array so I try to print it in a file using file_put_contents() but when I try to send a mail it's stuck and nothing... (no file either)

How to get it ?

Thanks


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;
}



Solution

  • Change this line from file_put_contents('file.txt', var_export($array)); to file_put_contents('file.txt', var_export($array, true));