How to link custom field of two custom post types?

Can you please elaborate some more? Is this custom field possibly an ACF field? For what is this custom field tied, for a single custom post? And should this linking impact all of the posts in both post types?

(Sorry, but I don’t have rights to make comments yet)

Supposing all of that, what I would suggest and probably do, is to create an ACF Options page and add this custom field there.

if( function_exists('acf_add_options_page') ) {     
    acf_add_options_page(array(
        'page_title' => 'Options'
    ));     
}

And then you can easily add the check for this field value on any place using function $value = get_field( 'your_custom_field', 'options' );


If what I supposed is wrong, please add some comments and correct me. There is a possibility to do exactly what you asked by using action hook save_post, but I just don’t think that would be such a great idea. You would have to take the custom field value from the current post, and then loop through all of the posts in both post types and alter the value there as well.


Update:

Since I got it all wrong what was the intention of the OP, which was actually this:

How to update the value of one ACF field when updating another

Here is the correct answer. Use the acf/update_value hook, in combination with update_field() function:

function wpse316844_on_custom_field_save( $value, $post_id, $field  ) {

    // do some checks to see if the field is the one you want

    update_field( 'another_custom_field', $value, $other_post_id )

}

add_filter('acf/update_value/name=custom_field_name', 'wpse316844_on_custom_field_save', 10, 3);