0

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

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

1 Answer 1

-1

Try update_post_meta function without esc_attr

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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