From 1f03cbaea105d2f442810809adf16ea9f4157227 Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Fri, 30 Jun 2017 10:05:03 -0400 Subject: [PATCH] glm_custom_fields filter only wpautop on textareas wpautop() was being applied to all results from the glm_custom_fields, so the query was expanded to check for the field's type, and only apply to textareas, so that not every field gets a paragraph tag wrapped around it. --- setup/frontHooks.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 916b023..4c7bf9a 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -111,10 +111,17 @@ add_filter('glm-member-db-fields-front-list-query-params', function( $query ){ add_filter('glm_custom_fields', function($attribute, $id = 0) { global $wpdb; - $query = "SELECT field_data FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data WHERE ref_dest = $id " - . "AND field_id IN (SELECT id FROM ".GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX."custom_fields WHERE field_name LIKE '$attribute' )"; - $result = wpautop($wpdb->get_var( $query )); - return $result; + $query = "SELECT D.field_data, F.field_type FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data D, ".GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX."custom_fields F " + . "WHERE D.ref_dest = $id " + . "AND D.field_id IN (SELECT id FROM ".GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX."custom_fields WHERE field_name LIKE '$attribute' ) " + . "AND F.field_name LIKE '$attribute'"; + + $result = $this->wpdb->get_row( $query, ARRAY_A ); + if ($result['field_type'] == 'textarea') { + $result['field_data'] = wpautop($result['field_data']); + } +// echo "
AA" . print_r($result) . "ZZ";
+    return $result['field_data'];
     },
     10,
     2
-- 
2.17.1