• Resolved brunojlt

    (@brunojlt)


    Hi,

    As the title says, I’m facing an issue where the free_text input from radio/checkbox is not being sent.

    The value is sent correctly in the email.

    Am I missing something?

    Tks,

    Bruno

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Mário Valney

    (@mariovalney)

    Hi!

    Is the plugin updated?
    We introduced that bug on 2.1.1, but fixed on 2.1.2.

    Thread Starter brunojlt

    (@brunojlt)

    Yep, I’m using 2.1.4 .

    Thread Starter brunojlt

    (@brunojlt)

    This is what I get from Zappier WebHook response:

    your-name: Meghan Brewer
    your-email: [email protected]
    your-subject: Ut voluptatem solut
    your-message: Velit ut esse fugia
    radio-277: Outro

    The radio-277 was selected as “Outro” with text input, but the value didn’t get there.

    Plugin Author Mário Valney

    (@mariovalney)

    Ooh. I see.

    The free_text option is not presented on CF7 configuration and I didn’t know it. Thanks for point that.

    Checking the docs I saw how it works and added a new feature:



    Now we will replace the value for last option with the “free_text” value.
    So we can support the radio “others” and still receive other selected options for checkboxes.

    I’ll ship a new version soon.

    • This reply was modified 4 years, 9 months ago by Mário Valney.
    Thread Starter brunojlt

    (@brunojlt)

    Thanks!

    Hey guys! I am trying to integrate a Automate.io webhook to the CF7 but there is a problem with the checkboxes.

    Let’s say I have checkbox named “interests”.
    As I test the received data in Automate.io I don’t get all my selected checkboxes but rather receive only the first and last checkbox from “interests” in the following 2 properties: “interests_first” and “interests_last”. I would like to get all selected checkboxes in one property named as it was in the form.

    How can I do that? Is this a bug or a configuration issue?

    PS: In the case where I select only 1 box from the checkbox the webhook receives “interests_first” and “interests_last” with the same value.

    PSPS: This first/last thing happen with every multi-select input. I use multi upload files plugin for CF7 and it’s the same behavior there.

    • This reply was modified 4 years, 8 months ago by zoroxx.
    • This reply was modified 4 years, 8 months ago by zoroxx.
    Plugin Author Mário Valney

    (@mariovalney)

    Hi Zoroxx.

    The plugin should send all selected values in with the named field.
    We don’t add “_first” or “_last” suffix.

    Please, create a new topic for your problem with form link.

    Thread Starter brunojlt

    (@brunojlt)

    In case someone needs a temporary solution, I updated the function get_data_from_contact_form in the /cf7-to-zapier/modules/cf7/class-module-cf7.php to get it working:

    private function get_data_from_contact_form($contact_form)
            {
                $data = [];
    
                // Submission
                $submission = WPCF7_Submission::get_instance();
                $files = (!empty($submission)) ? $submission->uploaded_files() : [];
    
                // Upload Info
                $wp_upload_dir = wp_get_upload_dir();
                $upload_path = CFTZ_UPLOAD_DIR . '/' . $contact_form->id() . '/' . uniqid();
                $upload_url = $wp_upload_dir['baseurl'] . '/' . $upload_path;
                $upload_dir = $wp_upload_dir['basedir'] . '/' . $upload_path;
    
                $tags = $contact_form->scan_form_tags();
                foreach ($tags as $tag) {
                    if (empty($tag->name)) {
                        continue;
                    }
    
                    // Regular Tags
                    $value = (!empty($_POST[$tag->name])) ? $_POST[$tag->name] : '';
    
                    // Tag with free_text option
                    foreach ($tag->options as $option) {
                        if ($option == 'free_text') {
                            // if array exists, there is input on the free_text option
                            if (array_key_exists('_wpcf7_' . $tag->type . '_free_text_' . $tag->name, $_POST)) {
                                $value = $_POST['_wpcf7_' . $tag->type . '_free_text_' . $tag->name];
    
                                $value = (!empty($value)) ? $_POST[$tag->name] . ': ' . $value : $_POST[$tag->name] . ': n?£o especificado';
                            } else {
    
                            }
                        }
                    }
    
                    if (is_array($value)) {
                        foreach ($value as $key => $v) {
                            $value[$key] = stripslashes($v);
                        }
                    }
    
                    if (is_string($value)) {
                        $value = stripslashes($value);
                    }
    
                    // Files
                    if ($tag->basetype === 'file' && !empty($files[$tag->name])) {
                        $file = $files[$tag->name];
    
                        wp_mkdir_p($upload_dir);
                        if (!copy($file, $upload_dir . '/' . basename($file))) {
                            $submission = WPCF7_Submission::get_instance();
                            $submission->set_status('mail_failed');
                            $submission->set_response($contact_form->message('upload_failed'));
    
                            continue;
                        }
    
                        $value = $upload_url . '/' . basename($file);
                    }
    
                    // Support to Pipes
                    $pipes = $tag->pipes;
                    if (WPCF7_USE_PIPE && $pipes instanceof WPCF7_Pipes && !$pipes->zero()) {
                        if (is_array($value)) {
                            $new_value = [];
    
                            foreach ($value as $v) {
                                $new_value[] = $pipes->do_pipe(wp_unslash($v));
                            }
    
                            $value = $new_value;
                        } else {
                            $value = $pipes->do_pipe(wp_unslash($value));
                        }
                    }
    
                    // Support to option
                    $key = $tag->name;
                    $webhook_key = $tag->get_option('webhook');
    
                    if (!empty($webhook_key) && !empty($webhook_key[0])) {
                        $key = $webhook_key[0];
                    }
    
                    $data[$key] = $value;
                }
    
                /**
                 * You can filter data retrieved from Contact Form tags with 'ctz_get_data_from_contact_form'
                 *
                 * @param $data             Array 'field => data'
                 * @param $contact_form     ContactForm obj from 'wpcf7_mail_sent' action
                 */
                return apply_filters('ctz_get_data_from_contact_form', $data, $contact_form);
            }
    Plugin Author Mário Valney

    (@mariovalney)

    Hi Bruno.

    A temporary solution for what? For free_text?
    It’s already shipped on new version (same day).

    Thread Starter brunojlt

    (@brunojlt)

    Oh, sorry, I didn’t notice!

    I’ll update the plugin.

    Plugin Author Mário Valney

    (@mariovalney)

    No problem.
    I hope all fits.

    Thread Starter brunojlt

    (@brunojlt)

    Hi, Mario, how are you?

    I faced another issue and tried to update the plugin (haven’t done that since now).

    Found two issues:
    1. The free_text is not being received at the WebHook, I can send you screenshoots, just tell me where is easier for you.
    2. When the checkbox is not exclusive, that is, more than one option can be selected, I get a Bad Request on my WebHook. When the checkbox is exclusive, the request works ok, but not receiving the free_text value.

    I’m using Microsoft Power Automate as WebHook, not Zappier.

    Can you please give a look?

    Plugin Author Mário Valney

    (@mariovalney)

    Hi, Bruno.

    The issues are from new version?

    Sounds like everything is OK here:

    The webhook body:

    {
      "_post_title": "Contact Form",
      "your-name": "Name",
      "your-email": "",
      "your-subject": "Subject",
      "radio-632": "Free Text",
      "checkbox-57": [
        "Op??o B",
        "Not exclusive free text"
      ],
      "your-message": ""
    }

    (you can add link to printscreen here. Just upload for imgur or another service, please)

    Thread Starter brunojlt

    (@brunojlt)

    Yep, I am using the latest version of the plugin.

    Regarding the Bad Request, I solved it changing the Data Type required in the schema by Microsoft Power Automate from string to array. Now all the options appear correctly.

    Now, regarding the missing free_text values, I think I found the problem.

    CF7 had a major update on 4th July: https://contactform7.com/2020/07/04/contact-form-7-52/#more-36548

    And it seems that they changed how the free_text field name in the POST array is added.

    Here is my form:

    [img]https://imgur.com/sVvjCp9[/img]

    [img]https://i.imgur.com/YyoV0MX.png[/img]

    Look at the debug here:

    [img]https://i.imgur.com/Sg0ACFS.png[/img]

    Look how the free_text doesn’t have the “_wpcf7_” prefix anymore.

    • This reply was modified 4 years, 8 months ago by brunojlt.
    • This reply was modified 4 years, 8 months ago by brunojlt.
    • This reply was modified 4 years, 8 months ago by brunojlt.
    • This reply was modified 4 years, 8 months ago by brunojlt.
    Thread Starter brunojlt

    (@brunojlt)

    Damn I can’t properly add images into the reply haha

    How did you do?

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘free_text input from radio/checkbox not being sent’ is closed to new replies.