我不完全理解你的问题-也许这会有帮助:
wp_insert_post(array(
// your woocomm post being inserted
));
// at insert, `save_post` will fire
add_action( \'save_post\', \'my_plugin_save_post\' , 10 , 3 );
function my_plugin_save_post($post_id, $post, $update) {
// check other firing of this: if this is a revision, get real post ID
if ( $parent_id = wp_is_post_revision( $post_id ) )
$post_id = $parent_id;
// you can condialize if you want to exicute on new posts (like `wp_insert_post`), or if you\'re UPDATEing a post
if ($update) {
// only run if post has been saved before
// ------ example: you can UPDATE the `post` itself with ------
// unhook this function so it doesn\'t loop infinitely
remove_action( \'save_post\', \'my_plugin_save_post\' );
// update the post, which calls save_post again
wp_update_post(
array(
\'ID\' => $post_id,
\'post_status\' => \'private\'
)
);
// re-hook this function
add_action( \'save_post\', \'my_plugin_save_post\' );
// ------ example: or you can do post meta work ------
if ($somthing == true)
update_post_meta($post_id, ...
// ------ example: or "call" other plugins ----
wc_update_product_stock(...);
} else {
// only run if post is brand new
}
}