• Resolved Snerfus

    (@snerfus)


    Having updated CF7 to 3.9, my hook for wpcf7_before_send_mail is now showing a blank value for posted_data.
    I have made it output to the error_log, and it comes up empty. Doing a print_r on the $cf7 does export a lot of values, but I see nothimng for posted_data.

    [code]
    add_action('wpcf7_before_send_mail', 'my_wpcf7_save');

    function my_wpcf7_save($cf7) {
    error_log(print_r($cf7->posted_data, true)); //blank
    error_log(print_r($cf7, true)); //not blank, all sorts of stuff

    return $cf7;
    }
    [/code]

    Has this been changed for 3.9, as 3.8x , everything worked fine.
    Thanks

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Same problem for me though the main data seems to function
    $wpcf7->id; & $wpcf7->title; etc and can set $wpcf7->skip_mail = 1;

    count($wpcf7->posted_data) ; // returns 0

    Have disabled all plugins except Contact Form 7
    Have removed the add_action(‘wpcf7_before_send_mail’,… from my functions,php
    and used instead a plugin – so 2 plugins active

    Removed child theme and running Twenty Fourteen.
    Would appreciate some assistance. It was working fine, doesn’t pay to have auto update.

    See: https://contactform7.com/2014/07/02/contact-form-7-39-beta/

    add_action(‘wpcf7_before_send_mail’, ‘my_wpcf7_before_send_mail’);
    function my_wpcf7_before_send_mail($form) {
    $submission = WPCF7_Submission::get_instance();
    $data = $submission->get_posted_data();
    }

    Thanks Rob W

    Thread Starter Snerfus

    (@snerfus)

    And then $submission->uploaded_files() will get all the attached files.
    Such a big change.

    Thank you Snerfus.
    Do you happen to know if there is a listing of the new functions somewhere?

    $wpcf7->skip_mail = 1; is not working in the wpcf7_before_send_mail hook? Any suggestions ?

    Thread Starter Snerfus

    (@snerfus)

    ericsyd, no, I do not, I had to look through the source code to find that new value.

    Karthi, the $wpcf7 variable is no longer accessible, you need to do it as above ($submission = WPCF7_Submission::get_instance();) etc,

    Many thanks @ericsyd . We can see the changes of CF7 here :
    https://contactform7.com/2014/07/02/contact-form-7-39-beta/

    Just wanted to chime in, in case any future me’s encounter this thread, to say the following worked seamlessly for our integration with the hubspot forms api:

    //$data = $cf7->posted_data;
    $submission = WPCF7_Submission::get_instance();
    $data = $submission->get_posted_data();
    strandcreative

    (@strandcreative)

    how does “wpcf7_before_send_mail” work with mail (2). i can get it to work with the actual mail that is sent out but the copied email which is sent to a different email address strips this out?

    The fix from richardgabriel has solved my issue. Many thanks. Wish I had seen it 3 days ago!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘wpcf7_before_send_mail does not pass posted_data’ is closed to new replies.