Using Gravity Forms ‘gform_stripe_field_value’ PHP filter

The gform_stripe_field_value filter can be used to modify a value before it is sent to Stripe. If you want to filter the value for any add-on, you can use gform_addon_field_value.

Usage

A generic example of how to use the filter, that includes a custom example with the comments “// your custom code here” then returns the first variable:

add_filter('gform_stripe_field_value', 'your_function_name', 10, 5);

To target a specific form, append the form id to the hook name:

add_filter('gform_stripe_field_value_10', 'your_function_name', 10, 4);

To target a specific field, append both the form id and the field id to the hook name:

add_filter('gform_stripe_field_value_10_3', 'your_function_name', 10, 4);

Parameters

  • $value (string): The value to be modified.
  • $form (Form Object): The Form currently being processed.
  • $entry (Entry Object): The Entry currently being processed.
  • $field_id (string): The ID of the Field currently being processed.
  • $meta_key (string): The custom meta key currently being processed (since version 2.1.1).

More information

See Gravity Forms Docs: gform_stripe_field_value

This filter was added in Gravity Forms 1.9.10.11.

The filter is located in GFStripe::maybe_override_field_value() in class-gf-stripe.php.

Examples

Change the value of a specific custom meta key

Modify the value of a specific custom meta key before sending it to Stripe:

add_filter('gform_stripe_field_value', function($field_value, $form, $entry, $field_id, $meta_key) {
    if ($meta_key == 'my_custom_key') {
        $field_value = 'my_custom_value';
    }
    return $field_value;
}, 10, 5);