With the post_updated
hook you can trigger an action when the post is updated. He passes 3 parameters:
$post_ID
(the post ID),$post_after
(the post object after the edit),$post_before
(the post object before the edit)
Here’s an example:
<?php
function check_values($post_ID, $post_after, $post_before){
echo 'Post ID:';
var_dump($post_ID);
echo 'Post Object AFTER update:';
var_dump($post_after);
echo 'Post Object BEFORE update:';
var_dump($post_before);
}
add_action( 'post_updated', 'check_values', 10, 3 ); //don't forget the last argument to allow all three arguments of the function
?>
See reference Codex
Related Posts:
- add action only on post publish – not update
- How to add a “publish” link to the quick actions
- Copy post to separate database with “add_action(….)”
- Send email to user when I publish a new post
- Action while post is being published
- Is there a action hook for the “Empty Trash” button?
- How to prevent posts from being published too close to each other?
- How to validate XML-RPC post creation and cancel when needed?
- Is it possible to Schedule Attachments in WordPress?
- Create posts on user registration
- Elegant way to include only published posts with get_objects_in_term()?
- How to publish a post with empty title and empty content?
- WordPress plugin to publish to multiple remote WordPress blogs
- Post publish only hook?
- Publish pending article from front end with a button?
- Action hook ‘wp’ firing twice… why?
- How to limit user to publish post per day and per role?
- When a user creates a post (pending), send a confirmation link that allows them to publish
- In what sequence are the hooks fired when a post is “published”?
- Restrict the Number of Posts an Author can Publish (over time)?
- Add javascript when post is published
- Count singular post views automatically
- featuring old articles without messing up with the archive
- Hiding by default specific post status on backend list?
- Detect Post Type when publish_post is ran
- Get the post_id of a new post
- Custom function for “Submit for Review” hook
- Does WordPress remove draft status automatically?
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- Prevent post from being published if no category selected
- Send email to user that his post has been rejected
- Limit number of posts a user can make per minute?
- How can I hook into creating a new post and execute wp_die(), before the post is inserted into the database?
- Every possible way to get data (posts) from WordPress
- publish_post conflicts with save_post
- add_action not using ‘delete_post’ action with wp_delete_post
- the_posts filter been called multiple time
- How can i do something after head like adding a hook for after head but before post
- Notification to Admin or Author upon new post [duplicate]
- What differences are there between a Privately Published post and a Draft post?
- Create cron job without a plugin?
- How to generate numbers indistinguishable for the IDs of the posts
- How to rename “Publish” metabox title in post screen
- count the total number of comments the user has received for his published posts
- Automatically Updating Publish Date Bug
- How can I schedule a PAGE to go live at a future date/time?
- How to give capability (publish contributors posts) to author role?
- Print a message if excerpt is empty after posts have been publish/update!
- Adding custom fields to bbpress reply form
- Check if checkbox is marked on publish/update post
- Decide user that can publish a post
- How to access $post from a callback function
- Prevent scheduled post being published if date/time is past current date/time
- Calling Different Custom Post Timestamps in a table
- Set static page/post from another blog on same network
- Do action on publish or update?
- transition_post_status hook doesn’t have any POST data when publish with Gutenberg [closed]
- Call Web Services on post first publish
- How to check if single.php has already called the_post_thumbnail function
- do more action after I publish a post
- What does WordPress do if I save a post without content/title? [duplicate]
- Assign published posts to another user automatically
- Divs appearing everywhere in post content
- Display password protected posts to logged in users
- Stop wordpress from creating empty/null entries
- Prevent posts with certain post_meta to be edited
- How to check in functions.php if there is data in a WP_Query?
- Update post meta within save_post action
- Automatically set post_parent value
- How can I tell if a post has been published at least once?
- Send email for pending post
- Post: how to set created date after post has been published [closed]
- Add delay to publish post
- Exists filter or action that change Add New Post link?
- Publish a Silent Post without updating Feed
- How can my plugin display a populated new post window
- Actions to use when flushing cache (when posts are added / deleted / modified)
- Is there a way to know when a page has been updated and do some action only once?
- How to set a Post’s default visibility to ‘Private’ in Gutenberg?
- WordPress doesn’t save or publish new posts
- Run a function when a custom post is update?
- Hook when post is set from published to draft?
- My posts are getting to Auto draft when I try to Publish
- How to publish a post if condition is met?
- WordPress get tags in “publish_post” hook
- Count singular post views automatically
- How publish post from pending status
- Bulk Post update_post_meta
- How can i take all ids from untrash_post action?
- Create blog post from external source and set publication date
- Grab meta data before post is saved
- Is it possible to completely replace a post with an action/filter?
- Hook To Get All Posts Deleted
- I want to send push notification just after publish a new post
- How to Test a Blog Post for Update vs. Publish Status — Unique
- How to handle a post before publishing?
- Return All Post from publish to draft [duplicate]
- I am creating a front end dashboard where I need to show all the posts by the current user. So, I need to show posts in publish
- Do anything on post_status change [duplicate]
- How can add custom commands in post-new.php in wordpress