In the end I checked against and updated a new meta value on each save.
$screen = get_current_screen();
if ( $screen->base == 'post' && $screen->post_type == 'sessions') {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
if ( isset( $_POST['session_status_tax'] ) ) {
$status = $_POST['session_status_tax'];
} else {
$status="";
}
$prev_term = get_post_meta( $post_id, 'prev_term', 'true' );
if ( $status === 'status-approved' && $status !== $prev_term ) {
write_post_log($post_id, 'Approved' );
send_email( $post_id, 'Approved' );
}
update_post_meta( $post_id, 'prev_term', $status );
}
}
Related Posts:
- Check for update vs new post on save_post action
- How to avoid infinite loop in save_post callback
- $update is always true in save_post
- Action hook ‘save_post’ triggered when deleting posts
- get post meta before it is updated (during SAVE_POST)
- save_post action firing before I publish / save the post
- save_post action only when creating a new post
- Minimum Word Count Before A Post Can Be Made Pending Review
- update_post_meta() not working in save_post
- How do I save each option in a multiple select menu as it’s own meta_key + meta_value pair?
- Update post on save
- Post meta checkbox becomes unchecked occasionally
- Return code from save_post action?
- update_post_meta not working in save_post
- save_post only saves meta data on second save
- Get Post ID with insert/edit link
- How to manage saving custom field from Quick edit and Post Save using save_post action hook without colliding each other?
- Why save_post_$(custom_post_type) is fired even if I am not already saving a post?
- Set the value of custom field when post is published or updated
- pass error to admin_notices on “quick edit”/save_post action
- save_post requiere at least one uploaded file to be published
- Get $_POST & $_REQUEST values before adding/updating post
- How can I create a new user account while creating a new post, and then set that new user as the author of that new post?
- Validate post checking if child term is assigned
- Clear cache on post of one type when something happens to post of other type
- Why not fire the save_post event?
- Compare custom taxonomies of updated post (or new post) [Updated with progress]
- WordPress 4.9.8 doesn’t save if content has style=”
- Reset all transients on post or page save
- Using PODS data with save_post
- Cant’t delete my custom posts
- where does this $post_id come from?
- Update current WP post every 3 minutes [closed]
- Changing new post to “pending” on publish – but “Publish failed” – why?
- update_post_meta not working in foreach
- Save post in another table
- Strange bug on post/page save
- draft_to_pending action doesn’t seem to fire
- What action to use for when a post is saved / published, with a caveat
- Custom wp_editor doesn’t update post_content
- Save custom value to main content of post
- Check for page template on save_post hook
- Access NEW/UPDATED post values in save_post() callback function
- save button grayed out randomly
- Post editor doesn’t save embed media [closed]
- How to get a post meta value and pass that to update_option when a post is created or updated?
- WordPress save meta data : Displaying the word Array when selected
- Save current post using custom save button
- Connection Reset on post/page save
- Meta data not saved on save_post
- Insert/Update DB table when making new post or update older one
- Prevent Page/Post From Being Created based on Pages/Posts per User per Time Unit
- How to debug | Some times the “Save Draft” button seems to spin but does not actually save
- My custom title gets duplicated at every save or post update
- Use save_post to generate file on wordpress
- Detect, if post is saved manually or programmatically in save_post-hook
- update_post_meta and update_field ony working when saving the post
- trigger save_post event programmatically
- Saving (Updating) Post / Page Edits With AJAX
- How to store the value of a custom field dropdown select for post referencing?
- Add post meta based on another post meta value before publish post
- How can i create a function to get youtube video time
- Remove image from post_content on save_post
- Execution of JavaScript on save post
- Have save_post write to database image meta [closed]
- How can you receive the most recent permalink or terms of the newly saved post?
- Correct processing of `$_POST`, following WordPress Coding Standards
- Frontend posting – everything saves other than checkboxes?
- update_post_meta() with a modified array?
- How to get post bulk edit action trigger and get edited post ids?
- Strange issue saving custom field data for a WooCommerce order
- Use the backbone.js client to save custom post type meta
- How to change image atributes right before an image to be saved?
- Getting gutenberg (WordPress 5) to save TInymce data?
- How to notify specific users when i’m posting/modifying a new post
- save_post hook is not called when post is saved
- What is the proper way to add a required field to a post type? [duplicate]
- displaying an error before update_post_meta
- WordPress publish_post hook not getting featured image and meta on first publish, but works on updating title
- Custom Meta Box (SELECT2) Not Saving Taxonomy Terms
- Save meta data with post, Without using any plugin [closed]
- Stripping URLs & Email from post submissions
- save_post not triggered when a post is updated
- Updating user meta on save post
- duplicate entries in database while using save_post or wp_insert_post
- Front end update_post_meta Help
- How to prevent meta data from being edited in a post?
- Catch and display error on save_post action
- Post meta is not accessible within save_post hook
- How to save post_status using action save_post?
- save_post doesn’t correctly process function call with php class
- Custom meta box data not saving
- set_post_format called after wp_update_post when using bulk edit?
- Custom metabox does not store data
- Generate slug and meta data if meta field is empty
- Problem with ‘save_post’ hook not running
- save_post not called in plugin / custom field still saving overwriting metaboxes
- Can this react script be optimized? How to make it faster
- Wp doesn’t save meta box data
- Get category of post inside save_post hook