$wpdb->insert not working inside save_post tag
Question
Will someone help me in this.
add_action( 'save_post', 'product_price_box_save' );
function product_price_box_save( $post_id ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
global $wpdb;
if ( wp_verify_nonce( $_POST['store_details_box_content_nonce'], 'store_details_box_content' ) ) {
if (is_int($_POST['store_pincode'])) {
# code...
$store_pincode = htmlentities(trim($_POST['store_pincode']));
}
$wpdb->insert($wpdb->shop_details, array(
'post_id' => get_the_ID(),
'shop_pincode' => $store_pincode,
), array("%d", "%d"));
$wpdb->show_errors();
}
}
Does anyone have idea why the data isn’t entered to database even the code looks good. Am I missing something or doing it wrong.
What I want to achieve is that when user publishes or updates the post the data should be saved to custom made database table.
Thanks.
0
custom-post-types, database, plugin-development
4 years
2020-05-25T03:11:21-05:00
2020-05-25T03:11:21-05:00 0 Answers
89 views
0
Leave an answer