How to update custom post custom field value when post is saved in admin?
I have tried to use this in misc.php for admin section:
add_action('pre_post_update', 'do_something_with_a_post');
function do_something_with_a_post($id) {
global $post;
update_post_meta($id, 'ct_Course_Dur_text_d19c', 'test12');
)
But it is not working.
You may try this (Using save_post hook), paste this code in your
functions.php
fileIn this example
sanitize_text_field( $_POST['your_custom_field'] )
is would be actually the cstom field on your form but you may use any hard coded data, replace theyour_custom_post_type
with your real custom post type.