I'm building a stripe plugin and I'm stuck on this minor major issue.
Problem: the form calls my process.php page to grab the form input variables, handle the Stripe token, and finally call out to Stripe to build a new customer based on all params being completed successfully. Once this sheet is called the wp functions in this sheet are all undefined.
My theory is that when the form requests the php sheet the server clears its cache and loads the requested sheet fresh, which dumps all the wp globals I need.
Question: how do I call from my form to my custom php sheet, and still have access to the wp global functions? small wrinkle, the form is built in another plugin
I hope this makes sense, let me know if I need to clarify this more.
folder structure:
plugins
-->other plugin
-includes
--template-functions.php(form is built here)
-->my plugin
-includes
-languages
-lib
-custom-form-processing.php
code:
form build in template-functions.php
<form id="<?php echo $form_id; ?>" action="<?php echo plugins_url() . '/lmf-stripe/includes/process-customer.php' ?>" method="post">
--inner form bits here
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<?php echo $newKey; ?>" data-amount="<?php echo $amount*100; ?>" data-description="<?php the_title_attribute(); ?>"></script>
</form><!--end #<?php echo esc_attr( $form_id ); ?>-->
process-customer.php
<?php
function setCustomer()
{
if (isset($_POST['action']) && $_POST['action'] == 'stripe' && wp_verify_nonce($_POST['stripe_nonce'], 'stripe-nonce')) {
global $stripe_options;
<!-- inner bits removed for brevity -->
// redirect back to our previous page with the added query variable
wp_redirect('http://www.google.com');
exit;
}
}
add_action('init', 'setCustomer');
?>