php - Get post meta returns "" when meta is set in code and not by using post edit page -


in admin screen, have input box. user selects date in input input box. when user clicks button date put meta field called "_yl_lease_security_refund_date" through ajax call method uses update_post_meta. can verify update_post_meta works because get_post_meta , send value in ajax response. however, if leave screen , come it, get_post_meta call returns "" value of input box unless meta value changed through edit post page. how can meta value updates persist? here method ajax calls:

function yeager_srr_post_date_refunded() {  $result = 'not updated'; if ( defined( 'doing_ajax' ) && doing_ajax ) {     $is_meta_updated = update_post_meta( $_post['lease_id'], '_yl_lease_security_refund_date', $_post['refund_date'] );     $meta_value = get_post_meta( $_post['lease_id'], '_yl_lease_security_refund_date', true);      if( $is_meta_updated !== false) {             $result = 'saved';     }     echo $result . '-' . $_post['lease_id'] . '-' . $_post['refund_date'] . '-meta_value=' . $meta_value; //. $value;       die(); } else {     wp_redirect( get_permalink( $_post['lease_id'] ) );     exit(); } } 

here code use put value in input box if value exits.

$security_refund_meta_value = get_post_meta( $row[6], '_yl_lease_security_refund_date', true); echo '<td>' . '<input type="text" name="date_refunded_' . $row[6] . '" id="date_refunded_' . $row[6] . '" value="' . $security_refund_meta_value . '" class="datepicker srr-refund-input" data-leaseid="' . $row[6] . '" data-refunddate="' . ( empty( $security_refund_meta_value ) ? '' : $security_refund_meta_value ) . '">' . '</td>'; 


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -