title: Gravity Forms custom validation filter
body: <p>I have a function that processes sales via a third-party service, processes the result and returns an array with the Status "Success" or "Invalid." This sales call is made using the gform_after_submission hook applied to the specific form.</p>
  
  <p>What I need to do is store the "Success" or "Invalid" result in the array as a variable that I can later pass to a function to validate or invalidate the credit card field, using gform_validation hook.</p>
  
  <p>I'm declaring the variable in a function, like so:</p>
  
  <pre><code>function foo { 
  ...code to sell product through API...
  
  $status = $checkoutShoppingCartRequest['Result']['Status'];
  }
  </code></pre>
  
  <p>When I print the variable $status within the function, it is showing either Success or Invalid like it should. </p>
  
  <p>Here is other function where I need to use this variable, passed to gform_validation, which fails every time regardless of Success or Invalid result:</p>
  
  <pre><code>function MBvalidate( $validation_result ) {
  $form = $validation_result['form'];
  if ( $status !== "Success") {
      $validation_result['is_valid'] = false;
      foreach( $form['fields'] as &amp;$field ) {
          if ( $field-&gt;id == '34' ) {
              $field-&gt;failed_validation = true;
              $field-&gt;validation_message = 'Your credit card could not be processed.';
              break;
          }
      }
  }
  //Assign modified $form object back to the validation result
  $validation_result['form'] = $form;
  return $validation_result;
  
  }
  
  add_filter( 'gform_validation_47', 'MBvalidate' );
  </code></pre>
  
  <p>I have tried passing the variable a number of different ways, via globals and sessions, etc.</p>
  
  <p>I am new to GF development so I am sure I'm missing something. I'd appreciate any direction.</p>