I am trying to email admin when an single custom post meta gets updated or deleted. This does not work with post save or post delete. All i need is to detect when this post meta gets updated or deleted and email admin.

so far i have tried to use this action but does not work:

function detect_post_meta_update($meta_id, $post_id, $meta_key, $meta_value)
  //code to email admin goes here

add_action( 'updated_post_meta', 'detect_post_meta_update', 10, 4 );

This was working but it was detecting all post meta changes including post view ... But currently is not working at all.

Any better way for building this notification system ?

1 Answer 1


Actually this is the right way of doing that and proper hook to work with in my opinion. All you need to do is check if the updated meta key is the one you want to detect (that's why there are 4 arguments passed to the hook!).

So let's say your post meta is called 'email_triggering_meta':

function detect_post_meta_update($meta_id, $post_id, $meta_key, $meta_value) {

     // ignore every meta update apart from `email_triggering_meta` 
     if ( 'email_triggering_meta' !== $meta_key ) {

     // code to email admin goes here
add_action( 'updated_post_meta', 'detect_post_meta_update', 10, 4 );
  • Yes actually i was not able to find better solution that this. But for some reason email is not getting send probably something related to mail function. Aug 25, 2018 at 13:02
  • please share the function that is responsible for sending the email, maybe we could advise. Aug 28, 2018 at 9:53

Your Answer

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

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