How to catch and modify custom field values when a page is updated

It all depends on how your “custom fields” are saved. If you store the values as post meta then you would have to call the update_post_meta function to update them on wp_insert_post_data. In the example below Im setting the post meta “my_meta_key” with the string value “my_meta_value”.

function save_my_post( $content ) {
    global $post;
    if( isset($post) && get_post_type( $post->ID ) == 'post' ){
        update_post_meta( $post->ID, 'my_meta_key', 'my_meta_value' );
    }
    return $content;
}
add_filter( 'wp_insert_post_data', 'save_my_post' );