• Hi! I’m Using Choices Callback Feature.

    //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. ??

    • This topic was modified 4 years, 7 months ago by virusking.
  • The topic ‘Choices Callback’ is closed to new replies.