Last active
May 21, 2020 09:57
-
-
Save New0/65b1b0dc194c23703e935a0fc22268a1 to your computer and use it in GitHub Desktop.
Reset Form after Stripe transaction cancelled in Caldera Forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Caldera Forms manage Stripe cancelation | |
* Description: Dispay a link that resets the form when returning from Stripe cancellation. | |
* Plugin URL: https://gist.github.com/New0/65b1b0dc194c23703e935a0fc22268a1 | |
* Author: New0 | |
*/ | |
add_filter( 'caldera_forms_pre_render_form', function( $html, $entry_id, $form ){ | |
//Check if we come back from Stripe with cancelled status | |
if( isset( $_GET["cf_stripe_status"] ) && $_GET["cf_stripe_status"] === "canceled" ){ | |
$request_uri = str_replace("&cf_stripe_status=canceled", "", $_SERVER["REQUEST_URI"]); | |
$current_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$request_uri"; | |
return '<div class="alert alert-warning">Stripe transaction was cancelled, <a href="' . $current_url . '" title="Reset Form"> reset the form here</a></div>'; | |
} | |
return $html; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment