How is it possible?
Best regards
]]>I used the “How to use choices callback feature” tutorial at https://docs.ultimatemember.com/article/1486-how-to-use-choices-callback in my registration form and it seems to function fine on the front-end. Select “Yes” for the question “Will you be attending LuNA 2021?” to see the fields in question.
While the parent field (Country) is saving to the database, the child field (Province/State) is not saving anything to the database, the field is “(empty).”
I used the same method for “Registration Type” and “region” with the same results.
I am testing as clean an install as possible, Twenty Fifteen theme, no plugins except those needed by the form, and I am using Ultimate Member 2.1.15.
Thanks in advance for all your help.
//Some parts of the code
function getCities( $has_parent = false ){
$parent_options = isset( $_POST[‘parent_option’] ) ? $_POST[‘parent_option’] : false;
$all_options = array(
‘AP’=>[‘Adilabad’,’Anantapur’,’Chittoor’,’Kakinada’,’Guntur’,’Hyderabad’,’Karimnagar’,’Khammam’,’Krishna’,’Kurnool’,’Mahbubnagar’,’Medak’,’Nalgonda’,’Nizamabad’,’Ongole’,’Hyderabad’,’Srikakulam’,’Nellore’,’Visakhapatnam’,’Vizianagaram’,’Warangal’,’Eluru’,’Kadapa’,],’AR’=>[‘Anjaw’,’Changlang’,’East Siang’,’Kurung Kumey’,’Lohit’,’Lower Dibang Valley’,’Lower Subansiri’,’Papum Pare’,’Tawang’,’Tirap’,’Dibang Valley’,’Upper Siang’,’Upper Subansiri’,’West Kameng’,’West Siang’,],
‘AS’=>[‘Baksa’,’Barpeta’,’Bongaigaon’,’Cachar’,’Chirang’,’Darrang’,’Dhemaji’,’Dima Hasao’,’Dhubri’,’Dibrugarh’,’Goalpara’,’Golaghat’,’Hailakandi’,’Jorhat’,’Kamrup’,’Kamrup Metropolitan’,’Karbi Anglong’,’Karimganj’,’Kokrajhar’,’Lakhimpur’,’Marigaon’,’Nagaon’,’Nalbari’,’Sibsagar’,’Sonitpur’,’Tinsukia’,’Udalguri’,],
‘BR’=>[‘Araria’,’Arwal’,’Aurangabad’,’Banka’,’Begusarai’,’Bhagalpur’,’Bhojpur’,’Buxar’,’Darbhanga’,’East Champaran’,’Gaya’,’Gopalganj’,’Jamui’,’Jehanabad’,’Kaimur’,’Katihar’,’Khagaria’,’Kishanganj’,’Lakhisarai’,’Madhepura’,’Madhubani’,’Munger’,’Muzaffarpur’,’Nalanda’,’Nawada’,’Patna’,’Purnia’,’Rohtas’,’Saharsa’,’Samastipur’,’Saran’,’Sheikhpura’,’Sheohar’,’Sitamarhi’,’Siwan’,’Supaul’,’Vaishali’,’West Champaran’,’Chandigarh’,],
‘CG’=>[‘Bastar’,’Bijapur’,’Bilaspur’,’Dantewada’,’Dhamtari’,’Durg’,’Jashpur’,’Janjgir-Champa’,’Korba’,’Koriya’,’Kanker’,’Kabirdham (Kawardha)’,’Mahasamund’,’Narayanpur’,’Raigarh’,’Rajnandgaon’,’Raipur’,’Surguja’,],
‘DN’=>[‘Dadra and Nagar Haveli’],’DD’=>[‘Daman’,’Diu’,]);
$arr_options = array();
if ( ! is_array( $parent_options ) ) {
$parent_options = array( $parent_options );
}
foreach ( $parent_options as $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 cities”;
} else {
$arr_options = array_unique( $arr_options );
}
return $arr_options;
}
Meta Key: user_city
so my question is that, if the user city is Hyderabad, then how can display it on any specific page??
Currently, I’m trying using via um_user(‘user_city’);
but it prints 5.
How can I print Hyderabad, instead of 5??
Sorry for the bad English. Thanks in Advance.
//Some parts of the code
function getCities( $has_parent = false ){
$parent_options = isset( $_POST[‘parent_option’] ) ? $_POST[‘parent_option’] : false;
$all_options = array(
‘AP’=>[‘Adilabad’,’Anantapur’,’Chittoor’,’Kakinada’,’Guntur’,’Hyderabad’,’Karimnagar’,’Khammam’,’Krishna’,’Kurnool’,’Mahbubnagar’,’Medak’,’Nalgonda’,’Nizamabad’,’Ongole’,’Hyderabad’,’Srikakulam’,’Nellore’,’Visakhapatnam’,’Vizianagaram’,’Warangal’,’Eluru’,’Kadapa’,],’AR’=>[‘Anjaw’,’Changlang’,’East Siang’,’Kurung Kumey’,’Lohit’,’Lower Dibang Valley’,’Lower Subansiri’,’Papum Pare’,’Tawang’,’Tirap’,’Dibang Valley’,’Upper Siang’,’Upper Subansiri’,’West Kameng’,’West Siang’,],
‘AS’=>[‘Baksa’,’Barpeta’,’Bongaigaon’,’Cachar’,’Chirang’,’Darrang’,’Dhemaji’,’Dima Hasao’,’Dhubri’,’Dibrugarh’,’Goalpara’,’Golaghat’,’Hailakandi’,’Jorhat’,’Kamrup’,’Kamrup Metropolitan’,’Karbi Anglong’,’Karimganj’,’Kokrajhar’,’Lakhimpur’,’Marigaon’,’Nagaon’,’Nalbari’,’Sibsagar’,’Sonitpur’,’Tinsukia’,’Udalguri’,],
‘BR’=>[‘Araria’,’Arwal’,’Aurangabad’,’Banka’,’Begusarai’,’Bhagalpur’,’Bhojpur’,’Buxar’,’Darbhanga’,’East Champaran’,’Gaya’,’Gopalganj’,’Jamui’,’Jehanabad’,’Kaimur’,’Katihar’,’Khagaria’,’Kishanganj’,’Lakhisarai’,’Madhepura’,’Madhubani’,’Munger’,’Muzaffarpur’,’Nalanda’,’Nawada’,’Patna’,’Purnia’,’Rohtas’,’Saharsa’,’Samastipur’,’Saran’,’Sheikhpura’,’Sheohar’,’Sitamarhi’,’Siwan’,’Supaul’,’Vaishali’,’West Champaran’,’Chandigarh’,],
‘CG’=>[‘Bastar’,’Bijapur’,’Bilaspur’,’Dantewada’,’Dhamtari’,’Durg’,’Jashpur’,’Janjgir-Champa’,’Korba’,’Koriya’,’Kanker’,’Kabirdham (Kawardha)’,’Mahasamund’,’Narayanpur’,’Raigarh’,’Rajnandgaon’,’Raipur’,’Surguja’,],
‘DN’=>[‘Dadra and Nagar Haveli’],’DD’=>[‘Daman’,’Diu’,]);
$arr_options = array();
if ( ! is_array( $parent_options ) ) {
$parent_options = array( $parent_options );
}
foreach ( $parent_options as $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 cities”;
} else {
$arr_options = array_unique( $arr_options );
}
return $arr_options;
}
Meta Key: user_city
so my question is that, if the user city is Hyderabad, then how can display it on any specific page??
Currently, I’m trying using via um_user(‘user_city’);
but it prints 5.
How can I print Hyderabad, instead of 5??
Sorry for the bad English. Thanks in Advance.
The choices are properly shown during “edit” mode.
BUT the values are not saved, and if there was a PRIOR value it is no longer displayed in view mode.
]]>What are the steps to populate the field, what should be in the
Choices Callback and Edit Choices fields in the editor when my function’s name is getCities() in functions.php?