3

I am using a calendar plugin. I have been using form data to create a new custom post type of calendar plugin and then update post meta custom fields for that calendar plugin. This works.

However there are other post meta that fired upon save_post action from the plugin classes.

I am trying to find a way to fire:

do_action( 'save_post', $post_id, $post, $update ); 

afterward. I have the $post_id but not the $post or $update. so that it fires all the methods as if I am clicking on save post in the admin.

Thank you,

1 Answer 1

2

You should be able to use wp_update_post() -https://codex.wordpress.org/Function_Reference/wp_update_post

Eg.

$my_post = array(
    'ID' => $post_id,
);

wp_update_post( $my_post );

The 'save_post' action should run when this function is called.

3
  • Yes, I used that, but still does not update all the post_meta (plugin and advanced custom fields) that update when I click "update" in the backend. May 11, 2018 at 23:31
  • Oh, you said: "I have been using form data to create a new custom post type of calendar plugin and then update post meta custom fields for that calendar plugin. This works." - So does your code not work then?
    – Mat
    May 11, 2018 at 23:33
  • When I use wp_insert_post and immediately update_post_meta, this works fine for the data I need to be there. But there are missing post meta that are created via the plugin classes or when you enter the same information (from insert_post, post_meta process that I created) and in the post edit page and click update/publish/draft May 12, 2018 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.