1

I am new to wordpress coding.

I've problem to get post_data in wordpress , because I can't var_dump (using ajax process) so I can not see full data, but in inspect in Chrome got parameter with this value

post_data: billing_first_name=&billing_last_name=&billing_country=ID&billing_address_1=&billing_address_2=&billing_city=&billing_state=&billing_city_ongkir=&billing_subdistrict_ongkir=

How can I get this data per field for example I want to get billing_first_name

2
  • 2
    Please show us your code. Commented Aug 27, 2018 at 4:42
  • Come up with the code you have tried where we can be able to debug the problem and give you a solution Commented Aug 27, 2018 at 4:45

1 Answer 1

1

Use the wordpress codex for help with wordpress coding issues. Wordpress encodes the POST data so you should use the stripslashes_deep function to access post data if the data is encoded using application/x-www-form-urlencoded or multipart/form-data .

$my_post = stripslashes_deep($_POST);
$my_value = $my_post['billing_first_name'];

See https://codex.wordpress.org/Function_Reference/stripslashes_deep

If you are posting the data using JSON you will need to use something more like this.

$json = file_get_contents('php://input');
$my_post = json_decode($json);
$my_value = $my_post['billing_first_name'];
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.