}
return $queryParts;
});
-add_filter('get_county_by_city', function( $city ) {
+
+add_filter('get_city_id_by_name', function( $city ) {
global $wpdb;
+
if (is_string($city)) {
- // Could make this a subquery below but this way it only gets run on member detail pages
- // where the city is not retrieved from $_REQUEST as an integer, but from $member.name as a string
$citySql = "SELECT C.id FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."cities C "
. "WHERE C.name = '$city' "
. "LIMIT 1"
. ";";
+ echo $citySql;
$city = $wpdb->get_var($citySql);
}
+ return $city;
+}, 10, 1);
+
+add_filter('get_county_by_city', function( $city ) {
+ global $wpdb;
$sql = "SELECT C.id FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."counties C "
. "WHERE C.id IN ("
break;
}
switch ($city) { // Find by city first, specific list given by client
- case 37: // Gaylord City
+ case 37: // Gaylord City
echo do_shortcode("[the_ad id='1182']"); // Show Gaylord Area CVB ad
break;
case 89: // Petoskey City
<div id="top-ad-container" class="row">
{if $member.city}
- {$memberCity = $member.city}
+ {$memberCity = apply_filters("get_city_id_by_name", $member.city)}
{$memberCounty = apply_filters("get_county_by_city", $member.city)}
{else}
{$memberCity = 0}