“update_post_meta” not working in “wp_insert_post_data” hook
Two issues with your code in current form: wp_insert_post_data hook runs before the actual insertion happens. In other words post might not not exist yet. Data in this hook does not contain post_id. More fitting hooks to use are those after post insertion is processed: do_action(‘save_post’, $post_ID, $post); do_action(‘wp_insert_post’, $post_ID, $post);