I'm trying to trigger a specific action when a custom post type that I've created is created/updated.
Ideally, I could run the same function/process of whether the post is:
- Created using the New Post screen in the WP Admin
- Updated using the Edit Post screen in the WP Admin
- Updated using the Bulk Edit function that I've created
- Updated using a Quick Edit
I've reviewed and experimented a bit with:
save_post_{custom_post_type}
pre_post_update
handle_bulk_actions-edit-{custom_post_type}
The save_post
hook would work except on a bulk update it appears it only gets called once with one post.
The handle_bulk_actions-edit
would work and I can iterate over the IDs provided but that excludes editing posts manually on the post edit screen, etc.
I also looked at update_{$meta_type}_metadata
as that hooks on specific metadata fields, but that seems like a hack given I really need it on the post level.
Is there one hook that gets called on ANY post add/edit that I can use regardless of the source of the edit (post edit screen, bulk edit, quick edit)? Or what is the best way to handle it?