Usage
add_filter('gform_stripe_api_mode', 'your_function_name', 10, 1);
Parameters
$api_mode
(string): The API mode, either “live” or “test”.
More information
See Gravity Forms Docs: gform_stripe_api_mode
Examples
Set API mode to live
Set the Stripe API mode to “live” for all forms:
function set_stripe_live_mode($api_mode) { return 'live'; } add_filter('gform_stripe_api_mode', 'set_stripe_live_mode', 10, 1);
Set API mode to test
Set the Stripe API mode to “test” for all forms:
function set_stripe_test_mode($api_mode) { return 'test'; } add_filter('gform_stripe_api_mode', 'set_stripe_test_mode', 10, 1);
Set API mode based on form ID
Set the Stripe API mode to “live” for form with ID 1, and “test” for other forms:
function set_stripe_api_mode_based_on_form_id($api_mode) { $form_id = rgget('id'); return $form_id == 1 ? 'live' : 'test'; } add_filter('gform_stripe_api_mode', 'set_stripe_api_mode_based_on_form_id', 10, 1);
Set API mode based on user role
Set the Stripe API mode to “test” for administrators and “live” for other users:
function set_stripe_api_mode_based_on_user_role($api_mode) { $current_user = wp_get_current_user(); return in_array('administrator', $current_user->roles) ? 'test' : 'live'; } add_filter('gform_stripe_api_mode', 'set_stripe_api_mode_based_on_user_role', 10, 1);
Set API mode based on a custom condition
Set the Stripe API mode to “live” if the custom condition is met, otherwise set it to “test”:
function set_stripe_api_mode_based_on_custom_condition($api_mode) { // Replace with your custom condition $custom_condition = true; return $custom_condition ? 'live' : 'test'; } add_filter('gform_stripe_api_mode', 'set_stripe_api_mode_based_on_custom_condition', 10, 1);