Saltar navegación

[Resuelto] How to test, retrieve and update values that are "drop down select" field types

This support ticket is created hace 3 años, 10 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Este tema contiene 1 respuesta, tiene 1 mensaje.

Última actualización por PaulS4783 hace 3 años, 10 meses.

Autor
Mensajes
#1966161

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

$country

variable is string.

But in this case the input field is a drop down selector.
I have tried:

 if ($country == '--- not set ---')

and

 if ($country == '')

but neither work.

What am I missing here?
Is this part of the problem:

$country = strval( $country );

?

#1966169

Solved.
My bad. One of the field slugs was misnamed.

if ($country == '')

works fine.