Update the order of the custom fields
authorSteve Sutton <ssutton@gmail.com>
Thu, 9 Aug 2018 10:25:09 +0000 (06:25 -0400)
committerSteve Sutton <ssutton@gmail.com>
Thu, 9 Aug 2018 10:25:09 +0000 (06:25 -0400)
order the custom fields by group then by their field order.

setup/adminHooks.php

index 4c93ad2..053d3cf 100644 (file)
@@ -278,9 +278,12 @@ add_filter(
     function( $content, $uid ){
         $fields = $this->wpdb->get_results(
             $this->wpdb->prepare(
-                "SELECT id,field_name
-                   FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields
-                  WHERE uid = %s",
+                "SELECT CF.id,CF.field_name
+                   FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields CF
+                        LEFT OUTER JOIN " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_groups FG
+                        ON ( FG.id = CF.gid )
+                  WHERE CF.uid = %s
+                ORDER BY FG.group_order,CF.field_order",
                 $uid
             ),
             ARRAY_A