Hi Everyone,
Here’s the new code snippet for the Parent Option with Callback Choices.
/**
* Parent dropdown callback
* @return array
*/
function um_my_parent_dropdown_options_callback(){
$array = array(
"a" => "A",
"b" => "B",
"c" => "C",
);
return $array;
}
/**
* Child dropdown callback
* @param boolean $has_parent
* @return array
*/
function um_my_child_dropdown_options_callback( $has_parent = false ){
$parent_option = $_POST['parent_option'];
$all_options = array(
"a" => array(
"apple" => "Apple",
"acre" => "Acre",
"amber" => "Amber",
),
"b" => array(
"d" => "D",
"e" => "E",
"f" => "F",
),
);
$arr_options = array();
if( isset( $all_options[ $parent_option ] ) ){
$arr_options = $all_options[ $parent_option ];
}elseif( ! isset( $_POST['parent_option'] ) ) {
foreach( $all_options as $k => $opts ){
$arr_options = array_merge( $opts, $arr_options );
}
}
return $arr_options;
}
Also, see: https://github.com/ultimatemember/ultimatemember/issues/450#issuecomment-524639349
Let me know if you’re still encountering any issues.
Regards,