From: Anthony Talarico Date: Fri, 3 Nov 2017 11:51:44 +0000 (-0400) Subject: adding filter to get all fields and values X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FmeetingsMI;p=WP-Plugins%2Fglm-member-db-fields.git adding filter to get all fields and values need all fields and values to loop througn in a theme template file --- diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 398026a..f08d140 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -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 "
AA" . print_r($result) . "ZZ";
+    return $result;
+    },
+    10,
+    2
+);
 add_filter('glm_custom_fields', function($attribute, $id = 0) {
 
     global $wpdb;