How can I check if a custom field was updated?

My post has a custom field named company_location.

Inside my functions.php file I am using the updated_post_meta hook to call a bg_update function I created.

I was expecting the function to var_dump the words it works at the top of my post edit screen after I change the company_location custom field on the post and click “update”.

But nothing happens. No var_dump shows at all.

function bg_update ($meta_id, $object_id, $meta_key, $_meta_value) {
$test = “it works”;
if ($meta_id == “company_location”) {
var_dump($test);
}
}
add_action( ‘updated_post_meta’, ‘bg_update’ );

What am I doing wrong?

Read more here:: How can I check if a custom field was updated?

Leave a Reply

Your email address will not be published. Required fields are marked *