l try this code :

add_post_meta($post_id, 'province', esc_attr($_POST['postProvince']), true);

checked : esc_attr($_POST['postProvince']

And it Contains Value

But add_post_meta insert null in database

it Happened only to province And city keys, other parameters insert into database correctly.

found problem area.

there is a plugin add this data to post (add_post_meta) and show into wp-admin Dashboard , method called by :

add_action( 'added_post_meta', 'ipc_add_to_post_meta', 10, 4 );

in plugin

when i try to use add_post_meta or update_post_meta insert null

wp version : 4.9.4

--------------- Update

problem is can not pass parameters using $_REQUEST And $_POST

  • Please include the whole block of code, to further diagnose the issues.
    – Den Isahac
    Feb 17 '18 at 16:58
  • What values does your DB table configuration allow in the province column? Feb 17 '18 at 19:41
  • i did not changed configuration i think it is nvar_char Feb 19 '18 at 16:39

Try update_post_meta function without esc_attr

    update_post_meta($post_id, 'province', $_POST['postProvince'], true);
  • You should never save user input directly into the database without sanitization. Use sanitze_text_field(), not esc_attr().
    – swissspidy
    Feb 18 '18 at 12:55
  • Post updated. Please check it out Feb 20 '18 at 20:42
  • why would this make any difference? Feb 25 '18 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.