Adding a filter to retrieve a particular attribute
authorLaury GvR <laury@gaslightmedia.com>
Mon, 10 Apr 2017 17:08:07 +0000 (13:08 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Mon, 10 Apr 2017 17:08:07 +0000 (13:08 -0400)
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.

setup/frontHooks.php
views/front/fields/list.html

index b8f8f22..cec957b 100644 (file)
@@ -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
index 00d7fd1..18f2674 100644 (file)
@@ -25,6 +25,5 @@
         $('.slash-price').prev().children('.msrp-value').addClass('sale');
         $('.red-hot').parentsUntil('.glm-member-list-record').addClass('red-hot-border');
         
-
     });
 </script>