title: CF7 Dynamically change form data
body: <p>I am trying to extend the CF7 plugin through their form tag filter to meet my needs, however I have run into a weird case. I have the following function (In my Theme Functions file) that somewhat works:</p>
  
  <pre><code>function custom_shortcode_handler( $tag, $unused ) {
      $formidable_array = get_related_vars(array('type' =&gt; 'cf7'));
  
      if ($tag[name] === 'user') {
          $tag[raw_values][] = $user;
          $tag[values][] = $user;
          $tag[labels][] = $user;
      }
      if ($tag[name] === 'display-name') {
          $tag[raw_values][] = $display_name;
          $tag[values][] = $display_name;
          $tag[labels][] = $display_name;
      }
      if ($tag[name] === 'email') {
          $tag[raw_values][] = $formidable_array[139];
          $tag[values][] = $formidable_array[139];
          $tag[labels][] = $formidable_array[139];
          if (!empty($formidable_array[223])) {
              $tag[raw_values][] = $formidable_array[139].', '.$formidable_array[298];
              $tag[values][] = $formidable_array[139].', '.$formidable_array[298];
              $tag[labels][] = $formidable_array[139].', '.$formidable_array[298];
          }
      }
      if ($tag[name] === 'phone') {
          $tag[raw_values][] = $formidable_array[135];
          $tag[values][] = $formidable_array[135];
          $tag[labels][] = $formidable_array[135];
      }
      if ($tag[name] === 'campaign') {
          $tag[raw_values][] = $campaign_name;
          $tag[values][] = $campaign_name;
          $tag[labels][] = $campaign_name;
      }
  
      return $tag;
  }
  add_filter('wpcf7_form_tag', 'custom_shortcode_handler', 10, 2);
  </code></pre>
  
  <p>On the Contact Form 7 side, I have the following fields:</p>
  
  <pre><code>[text user]
  [text display-name]
  [text email]
  [text phone]
  [text campaign]
  </code></pre>
  
  <p>Each one of these text fields is correctly updated by the function above, except for the phone field. I've tried switching that field to tel, number, text area, hidden, to no avail. It just doesn't retrieve the value, but if I replace <code>$formidable_array[135]</code> with any string (that has no numbers) it would work. If I put in any digits, it doesn't anymore or practically just takes out the digits and leaves the letters.</p>
  
  <p>Do keep in mind that <code>$formidable_array[135]</code> is not the issue because it can be replaced by any number inside quotes and the output remains the same.</p>
  
  <p>Something weird to note is that if I were to print out the <code>$tag</code> array within the if-statement as such:</p>
  
  <pre><code>    if ($tag[name] === 'phone') {
                  $tag[raw_values][] = $formidable_array[135];
                  $tag[values][] = $formidable_array[135];
                  $tag[labels][] = $formidable_array[135];
                  echo '&lt;pre&gt;';
                  print_r($tag);
                  echo '&lt;/pre&gt;';
              }
  </code></pre>
  
  <p>It would print the <code>$tag</code> array twice, first with the correctly inserted phone values (i.e. raw_values, values, and labels all set to '1234567890'), followed by a repost with all the values set back to null.</p>
  
  <p>I am somewhat convinced that they've some kind of Regex cleaner within the plugin code for digits for whatever reason but I cannot find it or figure out a way to resolve this.</p>
  
  <p>Any help is much appreciated.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Seems that if I replace <code>$formidable_array[135]</code> with the following:</p>
  
  <pre><code>    if ($tag[name] === 'phone') {
                  $tag[raw_values][] = '123-123-1234';
                  $tag[values][] = '123-123-1234';
                  $tag[labels][] = '123-123-1234';
              }
  </code></pre>
  
  <p>It works... Don't get why though, because $formidable_array[135] holds the same value if echo'd instead.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I need to figure out what's calling my function a 2nd time, doing a <code>var_dump()</code> on my <code>$formidable_array(135)</code> made me discover that the 2nd time that variable is printed out, it's NULL. So the "wpcf7_form_tag" hook is getting executed twice??</p>