adding filter to get all fields and values meetingsMI
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 3 Nov 2017 11:51:44 +0000 (07:51 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 3 Nov 2017 11:51:44 +0000 (07:51 -0400)
need all fields and values to loop througn in a theme template file

setup/frontHooks.php

index 398026a..f08d140 100644 (file)
@@ -126,6 +126,30 @@ add_filter( 'glm-member-db-fields-front-list-query-params', function( $query ){
     }
     return ( !empty( $queryParams ) ? $query . '&'.implode( '&', $queryParams): $query);
 },10, 1);
+
+add_filter('get_glm_custom_fields', function($uid,$entity_id) {
+    global $wpdb;
+    $fieldsTable   = GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields";
+    $dataTable     = GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data";
+
+    $query = "SELECT $dataTable.field_data, $fieldsTable.field_type, $fieldsTable.field_name "
+    . "FROM $dataTable "
+    . "LEFT JOIN $fieldsTable "
+    . "ON $dataTable.field_id = $fieldsTable.id WHERE $dataTable.entity_id = $entity_id;";
+    
+    $result = $this->wpdb->get_results( $query, ARRAY_A );
+    foreach($result as $key=>$value){
+        if ($result[$key]['field_type'] == 'textarea') {
+            $result[$key]['field_data'] = wpautop($result[$key]['field_data']);
+        }
+    }
+    
+//    echo "<pre>AA" . print_r($result) . "ZZ";
+    return $result;
+    },
+    10,
+    2
+);
 add_filter('glm_custom_fields', function($attribute, $id = 0) {
 
     global $wpdb;