I want to update/delete a post meta when a custom post (in this case custom post type is “booking”) is updated upon the change of post meta . In my case if user change the post meta booking_status
to ‘denied’ and then update the post, then I want to delete the post_meta booking_status
immediately .
Here is what I have tried
add_action( 'save_post', 'booking_status_is_updated' );
function booking_status_is_updated(){
global $post;
if($post->post_type =='booking'){
if(get_post_meta($post->ID,'booking_status',true)=='denied'){
delete_post_meta($post->ID,'booking_slot');
}
}
}
But this is not working ? How can I get it done ?