Dynamic Country-State-City Dependent Dropdown fields

This document provides the code necessary to populate custom callback dropdowns for Country, State, and City fields. We recommend reading this article thoroughly to understand the choices callback feature in detail. For implementing dynamic, dependent dropdowns for these fields, you can use the Country State City Dropdown (Pro) plugin. This third-party plugin integrates seamlessly with Ultimate Member forms, enabling auto-population of options based on user selections and facilitating a smooth setup with the callback functions below.

To begin, you should add the provided code snippet located at the end of this article to your theme's functions.php file or utilize the Code Snippets plugin.

Custom Country Dropdown Field Settings

In your custom country dropdown field setting, paste in the Choices Callback option the function name   um_customcb_populate_countries into the field's "Choices Callback" setting.

Custom State Dropdown Field Settings

In your custom state dropdown field setting, paste in the Choices Callback option the function name um_customcb_populate_states  into the field's "Choices Callback" setting. Select the country field in the Parent Option setting to link these fields.

Custom City Dropdown Field Settings

In your  custom city dropdown field setting, paste in the Choices Callback option the function name um_customcb_populate_city  into the field's "Choices Callback" setting. Select the state field in the Parent Option setting to link these fields.

WARNING: We have created this code example to provide guidance and to make it easier for you to implement this code into your website. However, we are not able to provide any support when it comes to customizing the plugin. If you need help implementing this code, please hire a developer.

Note: You can add the code snippet to your theme's functions.php file or use the Code Snippets plugin.