Add post meta based on another post meta value before publish post
The solution is using added_post_meta and updated_post_meta hook . Here is the working code . add_action( ‘added_post_meta’, ‘add_custom_field_automatically’, 10, 4 ); add_action( ‘updated_post_meta’, ‘add_custom_field_automatically’, 10, 4 ); function add_custom_field_automatically( $meta_id, $post_id, $meta_key, $meta_value ) { if ( ‘_my_meta_key’ == $meta_key ) { add_post_meta($post_id, ‘_my_new_meta_key’, $meta_value.’to something new’, true); } }