Add order by clause to city name filter
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 10 Jul 2018 16:12:02 +0000 (12:12 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 10 Jul 2018 16:12:02 +0000 (12:12 -0400)
For list of city names used in the city search filter on front end.

setup/frontHooks.php

index a2c661a..a1baf41 100644 (file)
@@ -77,7 +77,12 @@ if (isset($this->config['addOns']['glm-member-db'])) {
 add_filter( 'glm-member-contact-cities', function(){
     global $wpdb;
     $contactCities = $wpdb->get_results(
-         "SELECT id, name FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities WHERE id IN (SELECT city FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts WHERE active = true)"
+        "SELECT id, name
+           FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities
+          WHERE id IN (SELECT city
+                         FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts
+                        WHERE active = true)
+        ORDER BY name"
     );
     return $contactCities;
 });