• In recent updates something changed and when I process form data with wpcf7_before_send_mail hook and use standard
    $submission = WPCF7_Submission::get_instance();
    $data = (array)$submission->get_posted_data();
    then before where there was drop-down, I received single entry value, but now it returns array
    This change broke many websites, forms, payments, etc…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,
    I have the same issue.

    $posted_data = $submission->get_posted_data();
    $post_title = array(‘post_title’ => $posted_data[ ‘yourtitle’ ], …)

    The above used to return ‘Mr’, ‘Mrs’, etc. It now returns ‘array’ after the update. The dropdown values are used for routing custom emails to various recipients and this process is now broken. I can confirm that single text fields seem unaffected.

    EDIT: It appears that the dropdown value are now returned wrapped within array, the selected value is simply at the zero key, ie. $posted_data[‘yourtitle’][0].

    Thanks.

    • This reply was modified 4 years, 5 months ago by robrandell.
    • This reply was modified 4 years, 5 months ago by robrandell.

    Did either of you get this fixed? My database is full of “array” entries instead of the chosen checkbox. Did you figure out what files to edit and how?

    Thanks in advance.

    If you are using the standard ‘wpcf7_before_send_mail’ hook to process the submission data, the submitted values are wrapped within an array and you can return the value simply be referencing the zero key, i.e. $posted_data[‘fieldname’][0]. I am unsure if this applies to checkbox groups in the same way, it seems to work for all other form fields though. You could try $posted_data[‘checkboxgroup’], $posted_data[‘checkboxgroup’][‘checkboxvalue’] or $posted_data[‘checkboxgroup’][‘checkboxvalue’][0] and see if that helps.

    Thanks.

    • This reply was modified 4 years, 1 month ago by robrandell.
    • This reply was modified 4 years, 1 month ago by robrandell.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘dropdowns returned as array’ is closed to new replies.