Track WordPress changes on post edit/save

I would like to know how to run a function when a meta information of a custom post type is changed.

For example, I have a radio box associated with a custom post type. And made it with metaboxes, and when I change the option, I would like to run a function.

Read More

How would I do that?

Related posts

Leave a Reply

1 comment

  1. Originally in OP’s question.

    I think I found what I wanted

    function do_my_stuff($post_ID)  {
       //do my stuff here;
       return $post_ID;
    }
    
    add_action('save_post', 'do_my_stuff');
    

    WordPress: executing function when saving or editing post

    But is it possible to track what changes were made?

    Yup, did it with your help diggy, but had to change something.

    function do_my_stuff($post_ID)  {
       $newvalue = $_POST['my_metabox_value'];
       echo $newvalue;
       $oldvalue= get_post_meta($post_id, 'my_metabox_value', true );
       echo $oldvalue;
    }
    
    add_action('pre_post_update', 'do_my_stuff');