Ultimate Member callback function issue
Question
I am trying to filter child drop-down inputs based on parent dropdown. For example, if I select a state I need to show the cities only in the selected state.
What I have done so far is added this below function in the functions.php file.
function getCities() {
//get the value from the 'parent' field, sent via the AJAX post.
$choice = $_POST['choose_mavatam1'];
switch($choice) {
case "Tamilnadu":
$cities = [
"Chennai" =>"Chennai",
];
break;
case "Karnataka":
$cities = [
"Bangalore"=>"Bangalore",
];
break;
default:
//code to do something if other options are not selected (throw an error, or set $cities to a default array)
$cities = ["no city"];
}
return $cities;
}
I called this below function in Choices Callback
field of ultimate member plugin for the parent field. The bug I face is the Edit Choices
becomes this switch case’s default value automatically as no city
when I used this callback function.
0
dropdown
3 years
2020-07-29T05:10:25-05:00
2020-07-29T05:10:25-05:00 0 Answers
37 views
0
Leave an answer