This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: AjaxSearchPro Events Manager. Double location towns

Home Forums Product Support Forums Ajax Search Pro for WordPress Support AjaxSearchPro Events Manager. Double location towns Reply To: AjaxSearchPro Events Manager. Double location towns

#23075
mar1eke_louisemar1eke_louise
Participant

Hi,

Thank you for your response. Yes, if I use the location_town, I get dupliactes of the towns since there are duplicates. Unfortunately this code did not do the trick. The location town names are still shown as duplicates.

add_filter('asp_cf_item_view', 'asp_em_locations_cf_filter', 10, 1);
function asp_em_locations_cf_filter($item) {
  if ( $item->asp_f_field == '_location_id' && class_exists('EM_Locations') ) {
    $location_ids = array();
    foreach ( $item->asp_f_dropdown_value as $k=>$v ) {
      if ( is_numeric($v[1]) ) {
        $location_ids[] = $v[2];
        unset($item->asp_f_dropdown_value[$k]);      
      }
    }

$locations = EM_Locations::get( array('location'=>array_unique($location_ids)) );

    if ( is_array($locations) && count($locations) > 0 ) {
      foreach ( $locations as $loc ) {
        $item->asp_f_dropdown_value[] = array(

			$loc->location_id, $loc-> location_town
        );
      }
    }
  }
  return $item;
}

It did not do anything, I tried SORT_REGULAR, but also to no avail.

Any other suggestions?

Thank you again,
Marieke