Support » Plugin: Contact Form 7 » Dropdown field post data and version 5.2.1

  • Just updated to 5.2.1 and my dropdown field is no longer passing data to ActiveCampaign via the API. When I convert the same field to a text field it is fine.

    Is there a change in how I need to fetch the posted_data for this field type? Seeing no errors and all other field are still being passed fine to Active Campaign.

    Thanks.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    I don’t know what the ActiveCampaign is.

    Mr_sordum

    (@paulcityhopper)

    Hey @takayukister,
    Hey @njalex1,

    I create PDF’s from submitted data. All dropdowns are getting chinese signs!?
    Something is wrong with them since the update.

    Can you check that?

    Regards
    Paul

    Thread Starter njalex1

    (@njalex1)

    @takayukister ActiveCampaign is a marketing automation platform.

    with 5.2.1, I am having issues trying to grab a dropdown field value from $posted_data array when using wpcf7_mail_sent’. It is not available anymore. Text fields and Text areas are fine. Is the value being unset? This had been working fine since last update.

    @paulcityhopper For me, the value is empty.

    Thread Starter njalex1

    (@njalex1)

    @takayukister I rolled back to 5.1.9 and it is working again. Can you tell me what in 5.2 was changed that will not allow any dropdown field submitted values to be available in the posted_data array when hooking into wpcf7_mail_sent?

    Hi,

    I’m having the same problem when getting the values of dropdown fields (select) via the $posted_data array.

    Rollback to previous version (5.1.9) solves the issue.

    Amy

    (@germanpearls)

    I’m having the same issue. Doing a var_dump it looks like the value of the list field is now inside an array.

    (My field “new-task-status” is a select field, notice how it’s being returned now.)

    array(7) {
      ["start-time"]=>
      string(15) "8/14/20 1:18 PM"
      ["client-name"]=>
      string(30) "xxxxxx"
      ["task-name"]=>
      string(48) "xxxxxx"
      ["time-notes"]=>
      string(4) "test"
      ["new-task-status"]=>
      array(1) {
        [0]=>
        string(0) ""
      }
      ["end-time"]=>
      string(15) "8/14/20 1:18 PM"
    }
    • This reply was modified 10 months, 1 week ago by Amy.

    For those having issues with dropdown fields in CF7 v5.2.1, the plugin now forces field values to be parsed as arrays rather than single values.

    Here is the culprit code in the submission.php file,

    if ( wpcf7_form_tag_supports( $type, 'selectable-values' ) ) {
      $value = (array) $value;
    
      if ( $tag->has_option( 'free_text' )
      and isset( $posted_data[$name . '_free_text'] ) ) {
        $last_val = array_pop( $value );
    
        list( $tied_item ) = array_slice(
          WPCF7_USE_PIPE ? $tag->pipes->collect_afters() : $tag->values,
          -1, 1
        );
    
        $tied_item = html_entity_decode( $tied_item, ENT_QUOTES, 'UTF-8' );
    
        if ( $last_val === $tied_item ) {
          $value[] = sprintf( '%s %s',
            $last_val,
            $posted_data[$name . '_free_text']
          );
        } else {
          $value[] = $last_val;
        }
    
        unset( $posted_data[$name . '_free_text'] );
      }
    }
    
    $value = apply_filters( "wpcf7_posted_data_{$type}", $value,
      $value_orig, $tag );
    
    $posted_data[$name] = $value;

    this will affect checkboxes and select (dropdown) fields. One potential way round this issue is to hook the filter wpcf7_posted_data_{$type} in order to force the value back to a singular value,

    add_filter('wpcf7_posted_data_select', 'force_singular_value',1,3);
    add_filter('wpcf7_posted_data_select*', 'force_singular_value',1,3);
    function force_singular_value($value, $original_submitted_value, $cf7_tag){
      return original_submitted_value;
    }

    hopefully this should resolve the problems you’re facing.

    @aurovrata I tried adding that code to my functions.php file but now it’s just returning “original_submitted_value” for the category and tag instead of actually using the original value.

    In my case I’m using isset to take the value defined in the dropdown and set it as a category:

    
    add_filter('cf7_2_post_filter-category','filter_category',10,3);
    function filter_category($value, $post_id, $form_data){
    if (isset($form_data['platforms'])) {
            $value[] = $form_data['platforms'];
          }
      return $value;
    }

    Is there a way to accomplish this same function with the value now being stored in an array instead of being “set”?

    marc2307

    (@marc2307)

    Same issue here. We’re using get_posted_data() to get the forms posted data and generate a csv from it in a custom function. The return value of all select fields is now an array. For now we’ve rolled back to Plugin-version 5.2 and it works just as it did before.

    Is this a permanent change or can we expect a rollback to the previous functionality for the select fields @takayukister ?

    Thank you and kind regards,
    Marc

    I tried adding that code to my functions.php file but now it’s just returning “original_submitted_value”

    ok, that’s odd. Likely a bug in the CF7 plugin not populating the original value properly.

    So here is a modification to my original function which will definitely work,

    add_filter('wpcf7_posted_data_select', 'force_singular_value',1,3);
    add_filter('wpcf7_posted_data_select*', 'force_singular_value',1,3);
    function force_singular_value($value, $original_submitted_value, $cf7_tag){
      if(is_array($value) && !is_array($_POST[$field])){
          $value = $_POST[$field];
        }
        return $value;
    }
    Mr_sordum

    (@paulcityhopper)

    @takayukister do you see this?
    A lot of people have the same issue.

    Mr_sordum

    (@paulcityhopper)

    @takayukister I removed the Plugin

    I had this same problem and I don’t know how to fix it, no one supports

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Dropdown field post data and version 5.2.1’ is closed to new replies.