Hi @snydez
Please try to use this code below:
/*Write here your own functions */
function custom_negara_dropdown() {
$coutries = array(
"FR" => "France",
"ES" => "Spain" ,
"ID" => "Indonesia",
);
return $coutries;
}
function custom_provinsi_dropdown( $has_parent = false ) {
$parent_options = isset( $_POST['parent_option'] ) ? $_POST['parent_option'] : false;
$all_options = array(
"ID" => array(
"Aceh" => "Aceh",
"Sumatera Utara" => "Sumatera Utara",
"Sumatera Barat" => "Sumatera Barat",
"Riau" => "Riau",
"Jambi" => "Jambi",
"Sumatera Selatan" => "Sumatera Selatan",
"Bengkulu" => "Bengkulu",
"Lampung" => "Lampung",
"Kepulauan Bangka Belitung" => "Kepulauan Bangka Belitung",
"Kepulauan Riau" => "Kepulauan Riau",
"DKI Jakarta" => "DKI Jakarta",
"Jawa Barat" => "Jawa Barat",
"Jawa Tengah" => "Jawa Tengah",
"DI Yogyakarta" => "DI Yogyakarta",
"Jawa Timur" => "Jawa Timur",
"Banten" => "Banten",
"Bali" => "Bali",
"Nusa Tenggara Barat" => "Nusa Tenggara Barat",
"Nusa Tenggara Timur" => "Nusa Tenggara Timur",
"Kalimantan Barat" => "Kalimantan Barat",
"Kalimantan Tengah" => "Kalimantan Tengah",
"Kalimantan Selatan" => "Kalimantan Selatan",
"Kalimantan Timur" => "Kalimantan Timur",
"Kalimantan Utara" => "Kalimantan Utara",
"Sulawesi Utara" => "Sulawesi Utara",
"Sulawesi Tengah" => "Sulawesi Tengah",
"Sulawesi Selatan" => "Sulawesi Selatan",
"Sulawesi Tenggara" => "Sulawesi Tenggara",
"Gorontalo" => "Gorontalo",
"Sulawesi Barat" => "Sulawesi Barat",
"Maluku" => "Maluku",
"Maluku Utara" => "Maluku Utara",
"Papua Barat" => "Papua Barat",
"Papua" => "Papua",
),
"FR" => array(
"Paris" =>"Paris",
"Marseille" => "Marseille",
"Lyon" => "Lyon",
),
);
$arr_options = array();
if ( ! is_array( $parent_options ) ) {
$parent_options = array( $parent_options );
}
$arr_options = array();
foreach ( $parent_options as $key => $parent_option ) {
if ( isset( $all_options[ $parent_option ] ) ) {
$arr_options = array_merge( $arr_options, $all_options[ $parent_option ] );
} elseif ( ! isset( $_POST['parent_option'] ) ) {
foreach ( $all_options as $k => $opts ) {
$arr_options = array_merge( $opts, $arr_options );
}
}
}
//code to do something if other options are not selected or empty match
if ( empty( $arr_options ) ) {
$arr_options[ ] = "no states";
} else {
$arr_options = array_unique( $arr_options );
}
return $arr_options;
}
function custom_kota_dropdown( $has_parent = false ){
$parent_options = isset( $_POST['parent_option'] ) ? $_POST['parent_option'] : false;
$all_options = array(
"Aceh" => array(
"Simeulue" => "Simeulue",
"Aceh Singkil" => "Aceh Singkil",
"Aceh Selatan" => "Aceh Selatan",
"Aceh Tenggara" => "Aceh Tenggara",
"Aceh Timur" => "Aceh Timur",
"Aceh Tengah" => "Aceh Tengah",
"Aceh Barat" => "Aceh Barat",
"Aceh Besar" => "Aceh Besar",
"Pidie" => "Pidie",
"Bireuen" => "Bireuen",
"Aceh Utara" => "Aceh Utara",
"Aceh Barat Daya" => "Aceh Barat Daya",
"Gayo Lues" => "Gayo Lues",
"Aceh Tamiang" => "Aceh Tamiang",
"Nagan Raya" => "Nagan Raya",
"Aceh Jaya" => "Aceh Jaya",
"Bener Meriah" => "Bener Meriah",
"Pidie Jaya" => "Pidie Jaya",
"Banda Aceh" => "Banda Aceh",
"Sabang" => "Sabang",
"Langsa" => "Langsa",
"Lhokseumawe" => "Lhokseumawe",
"Subulussalam" => "Subulussalam",
),
"DKI Jakarta" => array(
"Kepulauan Seribu" => "Kepulauan Seribu",
"Jakarta Selatan" => "Jakarta Selatan",
"Jakarta Timur" => "Jakarta Timur",
"Jakarta Pusat" => "Jakarta Pusat",
"Jakarta Barat" => "Jakarta Barat",
"Jakarta Utara" => "Jakarta Utara",
),
"Jawa Barat" => array(
"Bogor" => "Bogor",
"Sukabumi" => "Sukabumi",
"Cianjur" => "Cianjur",
"Bandung" => "Bandung",
"Garut" => "Garut",
"Tasikmalaya" => "Tasikmalaya",
"Ciamis" => "Ciamis",
"Kuningan" => "Kuningan",
"Cirebon" => "Cirebon",
"Majalengka" => "Majalengka",
"Sumedang" => "Sumedang",
"Indramayu" => "Indramayu",
"Subang" => "Subang",
"Purwakarta" => "Purwakarta",
"Karawang" => "Karawang",
"Bekasi" => "Bekasi",
"Bandung Barat" => "Bandung Barat",
"Pangandaran" => "Pangandaran",
"Depok" => "Depok",
"Cimahi" => "Cimahi",
"Banjar" => "Banjar",
),
);
$arr_options = array();
if ( ! is_array( $parent_options ) ) {
$parent_options = array( $parent_options );
}
$arr_options = array();
foreach ( $parent_options as $key => $parent_option ) {
if ( isset( $all_options[ $parent_option ] ) ) {
$arr_options = array_merge( $arr_options, $all_options[ $parent_option ] );
} elseif ( ! isset( $_POST['parent_option'] ) ) {
foreach ( $all_options as $k => $opts ) {
$arr_options = array_merge( $opts, $arr_options );
}
}
}
//code to do something if other options are not selected or empty match
if ( empty( $arr_options ) ) {
$arr_options[ ] = "no states";
} else {
$arr_options = array_unique( $arr_options );
}
return $arr_options;
}
Just please make sure that you have set the provinsi in usermeta with not numeric values e.g. ‘Aceh’
Best Regards!