- 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_post
only 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
- Passing error/warning messages from a meta box to “admin_notices”
- How can I get the post ID from a WP_Query loop?
- How to edit a post meta data in a Gutenberg Block?
- How we get_post_meta without post id
- What is the code to get the download link for a product in WooCommerce?
- How to update/delete array in post meta value?
- Get updated meta data after save_post hook
- Manipulating post meta in the customizer
- How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
- How do I save each option in a multiple select menu as it’s own meta_key + meta_value pair?
- Why am I getting an infinite loop with have_posts?
- How to store post meta in an array?
- adding a URL to a post meta
- Adding meta data to an attachment post
- Trigger “unsaved changes” dialog for custom post meta changes
- Job of meta_key meta_value fields in database tables
- Post IDs missing on delete_postmeta action hook
- How to store Gutenberg ColourPicker RGBA as metadata
- Is it possible to update a post meta field through REST API if the format of it when registered is nested?
- Views count with time limit per IP
- Query 2 meta key values and a category
- trying to do if post meta !=0
- Trying to get file name
- how to build (custom) stats for post views, per month
- get_post_meta pagination
- Removing Post Meta from Category Pages?
- Hey, I want the second options. get_post_meta()
- Update post meta in woocommerce order frontend
- echo image caption
- populate post meta in gravity forms [closed]
- Get Meta Key Value While Saving Post
- Generate multiple goo.gl shortlinks for qtranslate bilingual blog
- Plugin with action ‘save_post’ needs to press publish twice on order to publish
- How to display post view count by date, week and month?
- How can I filter posts when the meta_value is a serialize object?
- Get User Post if Private
- How to receive all the meta information of a post ?
- add_post_meta adds meta to one more different post
- Unknown characters added to meta data values
- Compare old meta with new post meta
- get_post_meta($post->ID) returns empty string when in preview mode of custom post type
- need to add add user names to the post for later retrieval or removal
- Like & Dislike functionality using JavaScript
- update_post_meta not working in plugin
- get_permalink vs the_permalink
- Updating my Post when expiry date is past
- update_post_meta not work [closed]
- How to remove Date from Meta Description on SERP?
- Allow only one post with specific meta value
- How to display sql query fired by posts_where
- Unfiltered html with update_post_meta
- How to validate select field in post meta?
- get meta value from page query
- why after saving meta value it’s saving all the values the one that i clicked?
- Update post meta within save_post action
- How does WordPress treats attachments metadata in post content?
- Retrieving post meta array (attachment)
- Stop `update_post_meta` from working each time page refreshes?
- wpdb->get_var – count author posts, meta value
- Displaying the ‘time ago’ for recent activity within a post/custom post type?
- add post meta front end edit
- How to query and update one colum in postmeta table?
- How to remove date from showing in meta description
- Search post overlapping dates – meta_query with meta_key
- How to save HTML data into SQL post_content column
- update post meta value with other post meta value
- Post Publish date not display on Umaya Child themes
- How to merge the database results into single result?
- Check For get_post_meta on Author Archive Page
- Negative meta_query if storing multiple post_meta values with shared meta_key
- What format is this and how to get value “lal” and “pila” from it
- Frontend query and does not need to log in [closed]
- Get data from custom table and update relative post_meta based on meta_key
- How to save a meta_value as a numeric value after I retrieve it via update_post_meta?
- Get or set values in post meta
- Display multiple meta_key/meta_values by single SQL query
- Programatically delete several attributes in _product_attributes in post meta
- Get post meta after insert post
- Data not displaying in text field
- WP-API + JS Backbone client – how to update post meta
- Proper Way to Sanitize Meta Input
- update_post_meta returning false when called during init
- Getting meta content from get_next_post & get_previous_post
- When importing posts to a new site if XML file has postmeta not setup on new server what happens?
- Cache metadata for set of posts
- Does post-meta belong in header?
- Problem with get_post_meta