Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

1 Answer

up vote 2 down vote accepted

(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.

share|improve this answer
    
appreciate you posting the answer even though it was a duplicate question. sorry about that! –  helgatheviking Apr 26 '12 at 15:27
    
thanks a bunch @stephen ;) –  Sagive SEO Jul 15 '12 at 10:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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