Update for billing city
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 14 Feb 2019 21:25:39 +0000 (16:25 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 14 Feb 2019 21:25:39 +0000 (16:25 -0500)
Add new billing city

models/admin/contacts/index.php

index 01cd30d..6aac15e 100644 (file)
@@ -872,6 +872,19 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts
             }
         }
 
+        if ($contactID && isset($_REQUEST['billing_city']) && $_REQUEST['billing_city'] == -1 && isset($_REQUEST['newBillingCityName']) && trim($_REQUEST['newBillingCityName']) != '') {
+            // Clean up city name
+            $cName = trim(filter_var($_REQUEST['newBillingCityName']));
+            // Try to add the city
+            require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php';
+            $Cities = new GlmDataCities($this->wpdb, $this->config);
+            $cID = $Cities->addCity($cName);
+            // If we got a city id back
+            if (is_int($cID) && $cID > 0) {
+                // Update submitted city value to use the new ID
+                $_REQUEST['billing_city'] = $cID;
+            }
+        }
     }
 
     /*