Skip to content

Instantly share code, notes, and snippets.

@joedooley
Created February 5, 2018 21:19
Show Gist options
  • Save joedooley/9f4e87d91180fe274c66b0c41fb74935 to your computer and use it in GitHub Desktop.
Save joedooley/9f4e87d91180fe274c66b0c41fb74935 to your computer and use it in GitHub Desktop.
Change Stripe API mode for targeted form.
<?php
/**
* Filters the API mode for a specific form to 'test'.
*
* @param $api_mode string Either 'test' or 'live'
*
* @return string Returns 'test' for targeted form. Otherwise,
* will return the value for the $api_mode setting.
*/
add_filter( 'gform_stripe_api_mode', function ( $api_mode ) {
// Change $form_id to the id of the form your targeting.
$form_id = 1;
$form = GFAPI::get_form( $form_id );
if ( $form ) {
return 'test';
}
return $api_mode;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment