Using Gravity Forms ‘gform_paypal_config_validation’ PHP filter

The gform_paypal_config_validation filter is used to validate custom settings or meta specified using the gform_paypal_action_fields or gform_paypal_add_option_group action hooks in Gravity Forms.

Usage

add_filter('gform_paypal_config_validation', 'your_function_name');

Parameters

  • $is_validation_error (boolean) – Indicates whether there was a validation error with the PayPal configuration.
  • $feed (Feed Object) – The PayPal feed configuration array.

More information

See Gravity Forms Docs: gform_paypal_config_validation

Examples

Validate custom options for third-party integration

This example validates custom options that were added to the PayPal configuration form using the gform_paypal_action_fields or gform_paypal_add_option_group hook, for integration with a fictional third-party application.

add_filter('gform_paypal_config_validation', 'validate_custom_config', 10, 2);

public static function validate_custom_config($is_validation_error, $feed) {
    $custom_options = rgars($feed, 'meta/custom_options');

    if (empty($custom_options['enable_thirdparty_options'])) {
        return $is_validation_error;
    }

    if (empty($custom_options['thirdparty_apikey']) || empty($custom_options['thirdparty_apipass'])) {
        return true;
    }

    return $is_validation_error;
}

Source Code: apply_filters('gform_paypal_config_validation', false, $feed)
This action hook is located in GFPayPal::save_feed_settings() in class-gf-paypal.php.