Skip Navigation

[Resolved] Upload country list for Custom Field of type Select

This support ticket is created 4 years, 6 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by simonM-5 4 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#1375977

Hi Toolset Support

Tell us what you are trying to do?
I have added a custom User field, of type Select, named Country (meta key=wpcf_country). Now I simply want to bulk upload the list of 193 countries via CSV.
After, I would like a fast, reliable way to upload the Spanish and German translations (via WPML)... .mo files?

Is there any documentation that you are following?
I am trying to find the current best practices recommended by Toolset, based on the multitude of CSV Importers available, both free and those recommended by Toolset (which are over 5 years old and only tested up to WP 3.7.31 according to https://wordpress.org/plugins/csv-importer/?!) and conflicting solutions in the Toolset Knowledge base. Some solutions in the Knowledge base appear to be old. Sadly in the amount of time I have spent searching around, I probably could have added them all manually by now via the GUI, but nevertheless, we may come across this issue again, so I would still like to know the current preferred method.

Is there a similar example that we can see?
This must be asked by all your customers who use directory/classifed sites I imagine?

What is the link to your site?
hidden link

Thanks and best regards
Simon

#1376173

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

If you want to import CSV with translations, you need WPML all import plugin:
=> https://wpml.org/documentation/related-projects/wpml-all-import-plugin-website-import-with-wpml/

If you have a Country post type and you just wanted to fill the country select dropdown options dynamically, then you can use the Types hook: wpt_field_options.

For example:

 add_filter( 'wpt_field_options', 'func_dynamic_populate', 10, 3);
function func_dynamic_populate( $options, $title, $type ){
    switch( $title ){
        case 'country':
            $options = array();
            $args = array(
                'post_type'        => 'countries',
                'post_status'      => 'publish');
            $posts_array = get_posts( $args );
            foreach ($posts_array as $post) {
                $options[] = array(
                    '#value' => $post->ID,
                    '#title' => $post->post_title,
                );
            }
            break;
    }
    return $options;
}

Where:
=> You should change 'country' to your custom field name.

More info:
=> https://toolset.com/documentation/programmer-reference/types-api-filters/#wpt_field_options

#1378921

HI Minesh

Sorry for the delay in answering. We are thinking of buying that import software anyway.

We don't have a Country post type, rather a Country custom field. We need to have all 193 countries in it.

Is it recommended to use a Custom user field for Countries or is a Country Post Type better?

Best regards
Simon

#1378939

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Actually - its depends on your requirement, how you setup the country entity. If you want to connect the things later on using relationship, it needs to be setup as post type, if you just want to attach the country to your user, you can go with custom user field.

However, if you are going to buy the import plugin, with that, you need to setup it up as post type. I suggest, you should check for both first and run a test and chose the best suitable option later.

#1379017

My issue is resolved now. Thank you!

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.