Thank you for your response Victor. I've made some modifications and still have no result set. print_r() and var_dump() should expose whatever is in the array, correct? When I use a non-FF form, these dump the array contents. When I use the send data api from the FF form, the array appears to be empty. Do you have any ideas why that might be?
What Formidable hook are you using to execute your callback function?
Sorry, I realized I didn't reply in the right spot, please see the below entry. POST is the action type on When entry is created.
Sorry, the form condensed the php code into an ugly mass.
I don't think it's ever going to work the way you want it to. In an API, POST is not a variable. It's an API's method property that can be POST, GET, PUT, PATCH, DELETE. The method determines how the data is handled on the receiving end.
The PHP $_POST associative array is a PHP session variable. If the connection to the user session is severed, $_POST no longer exists. You are passing Formidable form values to your raw code through the API add-on. The add-on is designed to work with APIs. API REQUESTs are formatted as JSON. You can see what an API request looks like in the network tab of your browser's development tools. Look at the XHR object whenever you see admin-ajax.php executed on your WordPress site. For transfers with the 200 response, the XHR object has both the REQUEST and RESPONSE. The JSON you send from WordPress is in the REQUEST BODY and needs to be converted to an object or array in your PHP code before you can scan it.
I have absolutely no idea how to tell you how to read and process a JSON REQUEST in your raw code. I don't know how your raw code can access it. Good luck in figuring this out. Come back and let us know how you solve it.
Well, not the answer I was hoping for! But I appreciate it nevertheless. Thanks for your ideas Victor and I will come back to the forum and post how it was solved when that happens.
Please login or Register to submit your answer
So, I created a plain old html form with an action to point to my debug code and with the following modification, it works with both var_dump() and print_r().
ob_flush();
ob_start();
#$post = var_dump($_POST);
$post = print_r($_POST);
fwrite($fh, ob_get_flush());
When the same debug is called by send API data with POST, Form field format, etc. it results in an empty array () in the output file. Yet the log shows success 200 code for the post and has data like
frm_request
%5Bplanname%5D=testing+123&%5B10%5D=Fixed+Wired&%5B11%5D=123&%5B12%5D=No&%5B13%5
I remain stumped. Perhaps the send API data doesn't really send a post to the external script?