Home › Forums › General Issues › Save Post Revisions › Reply To: Save Post Revisions
I have recently found something new that might help those looking to prevent multiple revisions. Please note that I have not tested this and it is just speculation at this time.
This filter in WP is called just before saving a post revision
$post_has_changed = (bool) apply_filters( 'wp_save_post_revision_post_has_changed', $post_has_changed, $last_revision, $post );
So, using this hook you could
add_filter('wp_save_post_revision_post_has_changed', 'my_prevent_post_revisions', 10, 3);
function my_prevent_post_revisions($post_has_changed, $last_revision, $post) {
// here you can do some checking
// for example if you only want to prevent revisions on a specific post type
// return false to prevent post revision
return $post_has_changed;
}
Then in your filter or function where you want the revision to be saved
// remove the prevent post revision filter
remove_filter('wp_save_post_revision_post_has_changed', 'my_prevent_post_revisions', 10);
// update the post
wp_update_post($args)
// add the filter again
add_filter('wp_save_post_revision_post_has_changed', 'my_prevent_post_revisions', 10, 3);
If anyone has a chance to test this let us know.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.