Post Meta in Save Post Hook
-
I don’t know why it’s so difficult to get and work with the post meta on post save. In the save_post filters, the post meta is not always available in the $_POST or $_REQUEST object, and the post meta from the database is not always updated by the time the hook is called.
There is an updated_postmeta hook in the meta field update, but that is not an ideal place to hook into when attempting to catch save/update post actions.
There is a wp_insert_post_data FILTER, but filters are used to modify data and return the modified data, actions are used to perform actions, so this too is not ideal.
The $postarr object should really be sent along with the save/update post action hooks so that ALL of the sent data can be manipulated after save. At the very least, the post meta.
I have never understood why I have to test a thousand different hacks just to get the post meta on save post to work with. And why when one works for some site, for some reason, it doesn’t work on others.
There is always some workaround, but the save post action hook is really where this stuff should be handled and the meta fields should be readily accessible to this action. Both a before and after save. If you would like me to provide use cases, I can.
- The topic ‘Post Meta in Save Post Hook’ is closed to new replies.