- Well, first use the hook properly. The post ID will be passed in. You
don’t need$post->ID. - Second, use the correct hook. If you want to run
save_postonly for
your booking type, usesave_post_booking
But otherwise, the code works. I just ran a quick test.
function booking_status_is_updated($post_id){
if(get_post_meta($post_id,'booking_status',true)=='denied'){
delete_post_meta($post_id,'booking_slot');
}
}
add_action('save_post_booking','booking_status_is_updated');
Related Posts:
- Execute action after post is saved with all related post_meta records (data)
- Add post meta based on another post meta value before publish post
- Get updated post meta on save_post action?
- Correct processing of `$_POST`, following WordPress Coding Standards
- Set default Custom Post Meta Value
- Save post meta foreach loop
- troubles with get_post_meta (and saving it)
- wp_insert_post inside save_post adds wrong metadata to inserted post
- post_title in save_post action
- Auto save title as custom meta field value
- Save frontend submission form field as custom field
- get_post_meta() returns nothing in save_post, publish_post, wp_after_insert_post
- if condition from post_meta not working in save_post
- Explanation of update_post_(meta/term)_cache
- Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
- Adding meta tag without plugin
- Meta compare with date (stored as string) not working
- How to update/insert custom field(post meta) data with wordpress REST API?
- Remove WordPress.org Meta link
- Front-end update_post_meta snippet displays white screen?
- How to get meta value in wp_attachment_metadata
- update_post_meta() not working in save_post
- Clean up output added via wp_head()
- Short of raw SQL, can I query for multiple attachment metadata that have a given array key?
- Get post from meta_key and meta_value
- get_post_meta returns bool(false)
- Problem With Order Item Meta In Woocommerce
- Mass importing json data into custom fields (postmeta)
- Best way to save postmeta
- How to echo get_post_meta (Fluent-Framework)
- How to update Post Meta values through the comment system
- Filtering multiple meta_values
- get_post_meta remains empty while looping all menu items and using the ID
- how do I set a schedule event to modify all posts’s meta value weekly or monthly?
- How to stop wp_postmeta from being called on archive and search pages?
- How to use update_post_meta() function properly?
- Set the value of custom field when post is published or updated
- WordPress front-end media (image) upload ERROR!
- running function during post save and adding variable to post meta
- update_post_meta saves nothing in database when run in publish_post
- Set default value field meta_Value [closed]
- Can’t access post meta on new post creation (cpt)
- Custom post meta values reset by autosave [duplicate]
- Compare meta_query with a Regular Expression and do a less-than operation on it
- Editing does not change post_name
- Compare string with post id in wpdb and do stuff when match is found
- $wpdb class updating meta_value using Ajax [closed]
- Is it possible to retrieve a post and its metadata at the same time?
- Post meta as array looks like string instead of array
- How to selected which tags to print, instead of printing the whole tag list?
- query posts and split meta information into separate div’s
- add unique string as custom-field to every post
- How do I insert a new meta key / value pair, but only if another meta key is present?
- “Cannot use import statement outside a module” JS error while adding a custom meta block?
- Change post author without using wp_update_post()
- Gutenberg featured image checkbox – checkbox not correctly set on editing page reload
- How to properly use oneOf and anyOf in Rest Schema?
- Get the author meta adds now
- wordpress is_front_page() issue
- show ad after # paragraphs
- If ACF meta_key has meta_value
- How we can get “get_post_meta” of specific user who added it
- Repeated nav bar queries failing to be cached
- Randomizing Post Links Outside of Loop – No Author or Date
- Check for page template on save_post hook
- help to decipher wp metadata
- Insert Custom Field Value
- SQL query – get a featured image’s alt / alternative text
- I can not display meta value in extras.php and template-tags.php
- update_post_meta() updating nested array in Multidimensional array with empty sub-array
- How do I list taxonomies that have upcoming events in WP? Is there a way to do this without having to query posts first?
- Sorting my posts on homepage my specific value in post_meta table
- Strict comparisons problem when using boolean post meta
- Why is the actual number of thumbnail images not matching what is store in an attachments metadata?
- update_post_meta() is not saving the value
- Only show meta on one post type on search results page
- Check if any meta on the post has value then display content
- Combine meta query and give a specific meta query a higher priority
- I created a Custom Meta Box but it is not displaying the value on my post page
- Get table parameter and save in meta value
- How can i show post views using specified post ID?
- How to add/update post meta to use in query?
- Get post content before rendering
- gettext localization is not working
- Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)
- Custom post type meta fields missing on save_post_type
- Saving post meta
- Multiple postmeta values to the same post_id/meta_key combination?
- Exclude category from DB query
- How to sort by meta value num, but ignore zero value?
- Create a Gallery and update Post Parent of Attachment Images
- Update event post meta each day automaticaly
- Advanced Custom Field — grabbing post_meta from previous post
- how to echo/display the custom field value in specific custom field name?
- How to create a link for wordpress meta datas?
- Fetch post meta data on POST request
- Which query method to use? (edit- wpdb syntax problems)
- How to update post meta with xml data
- wp_postmeta store multiple values in one key [closed]
- How we insert values into database using metabox WordPress?