-
-
Save pije76/ec82352e9d6bbee6c1c299eb8e1667bd to your computer and use it in GitHub Desktop.
Example Callback function for Ultimate Member dropdown field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCities() { | |
//get the value from the 'parent' field, sent via the AJAX post. | |
$choice = $_POST['parent_option']; | |
//Depending on the value of $choice, return a different array. | |
switch($choice) { | |
case "France": | |
$cities = [ | |
"Paris" =>"Paris", | |
"Marseille" => "Marseille", | |
"Lyon" => "Lyon" | |
]; | |
break; | |
case "Spain": | |
$cities = [ | |
"Madrid"=>"Madrid", | |
"Barcelona"=>"Barcelona" | |
]; | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment