From: Laury GvR Date: Mon, 10 Apr 2017 17:08:07 +0000 (-0400) Subject: Adding a filter to retrieve a particular attribute X-Git-Tag: v1.0.0^2~45 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=efb98944ffdfb0e5cb7a7a7213cdd08ce99ef11d;p=WP-Plugins%2Fglm-member-db-fields.git Adding a filter to retrieve a particular attribute Added a filter to fronthooks so that the theme can apply_filter to get a given attribute. This was done so Brewbakers could get the Year of a certain member. --- diff --git a/setup/frontHooks.php b/setup/frontHooks.php index b8f8f22..cec957b 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -49,3 +49,14 @@ add_filter('glm-member-db-front-search-query', function($query) { //$query .= " AND T.member IN (SELECT id from " . GLM_MEMBERS_PLUGIN_DB_PREFIX. "members WHERE member_type = 2 ) "; return $query; }); +add_filter('glm_custom_fields', function($attribute, $id) { + + 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 = $wpdb->get_var( $query ); + return $result; + }, + 10, + 2 +); \ No newline at end of file diff --git a/views/front/fields/list.html b/views/front/fields/list.html index 00d7fd1..18f2674 100644 --- a/views/front/fields/list.html +++ b/views/front/fields/list.html @@ -25,6 +25,5 @@ $('.slash-price').prev().children('.msrp-value').addClass('sale'); $('.red-hot').parentsUntil('.glm-member-list-record').addClass('red-hot-border'); - });