Are there any actions I can hook into for update_post_meta()? I don't see anything obvious in the source. Woocommerce lets you change the featured status of items via ajax from the edit screen. I am using a transient to store the featured items in lieu of querying them every time and I'm deleting that transient on the save_post hook, but it isn't getting fired because of the ajax function that directly updates the post meta. Worst case I can unhook woo's action and recreate it myself with the delete transient call, but I'm wondering if there is another hook i could use.
-
Maybe that already answers what you are looking for? wordpress.stackexchange.com/questions/16835/… – Thomas Apr 26 '12 at 14:55
-
... I wish I'd searched first... – Stephen Harris Apr 26 '12 at 15:03
-
yeah me too. face palm. – helgatheviking Apr 26 '12 at 15:09
(See codex) update_post_meta()
calls
update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
This function is here. And there are plenty of hooks/filters:
(In example of 'post', $meta_type='post'
)
Before metadata is updated:
update_{$meta_type}_metadata
(here) Filter
-If this returns anything other than 'null', the metadata won't save
update_{$meta_type}_meta
(here) Action
After metadata is updated:
updated_{$meta_type}_meta
(here) Action
updated_post_meta
(here) Action
-For posts only
All the actions take ($meta_id, $object_id, $meta_key, $meta_value)
as arguments. The filter filters a $check
and takes the above as additional arguments.
-
appreciate you posting the answer even though it was a duplicate question. sorry about that! – helgatheviking Apr 26 '12 at 15:27