I’ve got a strange issue here.
I have a number of posts that will be created automatically with an xlm import to a custom post type.
The post type has two pre-set dropdown fields – Position and Location.
The import’s values for these fields is different than the options available – and I can’t change the import, or the existing field dropdowns.
So my thought is, would there be a way if I add new fields for the import data, then on post save have a conditional statement that would update the existing fields based on imported field info.
So for example, if the pre-set field for ‘MyLocation’ has dropdown options like:
Vancouver (West)
Vancouver (East)
and the importing xml has an address
“123 Main St. Vancouver”
which is imported into a basic text field.
Then i’d need to run a script that has “if XMLLocation = ‘123 Main St.’ then MyLocation = ‘Vancounver(West)’.
I’m thinking the “acf/save_post” action would be able to do this, but was unsure how to set it up.
I’m assuming the import plugin will trigger a post save when importing.
Then something like :
add_action('acf/save_post', 'change_location', 5);
function change_location( $post_id ) {
$locationField = get_field("location");
$xmlLocationField = get_field("xml-location");
if $xmlLocationField = "123 Main St." {
$locationField = "Vancounver(West)";
}
Does this make sense? Is it possible to change a field based on a second field’s value?