WordPress Webhook

2013 年 5 月 8 日5210

I have a problem that I am not sure how to fix.

I have a formstack form on my wordpress site. It allows people to buy a product. For this

particular page, there is only one item available for sale, so once the

form is processed (data sent to Formstack->Stripe and payment confirmation received),

the page needs to "turn off" so others can't purchase the item.

Before I used formstack, I used gravity forms plugin.

When the form submitted, I had a add_action filter in my functions.php in

wordpress. It fired when gravity forms completed the submission process and

ran a function that turned off the page.

Here is that code that worked beautifully.

add_action("gform_after_submission", "set_post_content", 10, 2);



function set_post_content(){







global $cfs;







$field_data = array('sold' => '1');



$post_data = array('ID' => get_the_ID()); // the ID is required



$cfs->save($field_data, $post_data);



}



I see formstack has a webhook function.

I cannot seem to find code on how to parse the data the formstack webhook sends. I used http://requestb.in/ to see the data that was being sent.

I believe I need to use php://input, but once I read the data, I am not sure how to say

If formstack webhook fires, then run this code

    function set_post_content(){







global $cfs;







$field_data = array('sold' => '1');



$post_data = array('ID' => get_the_ID()); // the ID is required



$cfs->save($field_data, $post_data);



}



I also believe the code needs to be in the functions.php in my theme file because otherwise it won't understand the $cfs variable that is from another wordpress plugin.

0 0