For credit card processing, I added the address text block. And I want to access address, city, state and zip separately in my php snippet.
I know how to access it in the email settings e.g. [x show="city"]. But how would I access the fields in my php snippet?
I tried:
$city = $_POST['item_meta'][734 show="city"];
But that doesn't work.
Does anyone know how to do this?
Thanks,
Roger
Thank you very much. This makes total sense, and I will follow up after I get to try it out.
Roger
Please login or Register to submit your answer
PHP $_POST isn't a shortcode. PHP $_POST is a PHP super global variable which is used to collect form data after submitting an HTML form with method="post". $_POST is also widely used to pass variables to the server.
You didn't say which hook you're using to access $_POST. But in order to understand how to access post variables, you need to know how Formidable defines the input names. The best way to see this is to use your browser's inspection tool and examine the input names.
For example, I just added an address block to a play form on my development server. When I look at them in the inspector, their field names are item_meta[1109][line1], item_meta[1109][line2], item_meta[1109][city], item_meta[1109][state], item_meta[1109][zip], and item_meta[1109][country].
The 1109 is my field id. Change it to your address block's field ID and you should be set.
$_POST generally has a lot of details besides just input values. If you use a debugger like Kint, you can see everything contained in $_POST.