I am trying to write a function to copy the value of an imported custom field (postalCode) to another custom field (wpcf-adres) when the post is saved or created. But i cannot get it to work, so there must be something not right in the code? Thanks for any advice or solution given!
function sync_postalcode( $post_id ) {
// GET Postal code FROM OTHER FIELD
$postcode = get_post_meta( $post_id, 'postalCode', true);
// UPDATE Postalcode IN adres FIELD
update_post_meta( $post_id, 'wpcf-adres', $postcode );
}
add_action( 'save_post', 'sync_postalcode' );