You do not want to reference the global $post
, but the post that is given to you as one of the argument. You simply need to remove global $post
;
Remember also to sanitize input and prefix function names.
function wpse50651_filter_transition_post_status( $new_status, $old_status, $post ) {
global $wpdb;
$wpdb->query(
$wpdb->prepare(
"UPDATE my_table SET post_status=%s WHERE post_id=%d",
$new_status,$post->ID
)
);
}
add_action('transition_post_status', 'wpse50651_filter_transition_post_status', 10, 3);