Make Revision Post hook

Description

The action hook is executed at the end of “make revision” action. Use this hook to copy data from original post to the revised post.

Usage


add_action('owf_duplicate_post', 'copy_post_meta_info', 10, 2);

Parameters

  • $new_id – ID of the new/revised post
  • $original_post – post to copy the data from

Example


add_action('owf_duplicate_post', 'copy_post_meta_info', 10, 2);

function copy_post_meta_info($new_id, $post) {
	$post_meta_keys = get_post_custom_keys($post->ID);

	if (empty($post_meta_keys)) 
		return;
	
	foreach ($post_meta_keys as $meta_key) {
	$meta_values = get_post_custom_values($meta_key, $post->ID);
		foreach ($meta_values as $meta_value) {
			$meta_value = maybe_unserialize($meta_value);
			add_post_meta($new_id, $meta_key, $meta_value);
		}
	}
}

Source Code

The action hook is located in class-ow-revision-service.php