This code isn't working for me.
$country = get_post_meta( $post_id, 'wpcf-consignee-country', true );
if ($country == '--- not set ---') {
$country = do_shortcode("[types field='client-country' output='raw' item='@client-username-vehicle.parent'][/types]");
$country = strval( $country );
update_post_meta( $post_id, 'wpcf-consignee-country', $country );
}
I have two post types Clients and Vehicles, connected by a post reference field.
I want the code to test to see if the "Consignee Country" field of the Vehicle record is blank.
And if it is blank, look up the "Country" field from the parent "Client" record and use that instead.
The above code works absolutely fine if the
variable is string.
But in this case the input field is a drop down selector.
I have tried:
if ($country == '--- not set ---')
and
but neither work.
What am I missing here?
Is this part of the problem:
$country = strval( $country );
?
Solved.
My bad. One of the field slugs was misnamed.
works fine.