From 822aa4da2cba5b391e41f051c75fb41720068977 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 13 Apr 2017 16:11:26 -0400 Subject: [PATCH] Adding filter to create the get parameters for custom fields. This will be used in the member list or grid when it builds the Alpha or the Previous Next page links. --- setup/frontHooks.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 5780748..557bcbc 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -116,6 +116,26 @@ add_filter('glm-member-db-front-search-query-orderby', function($originalOrderBy $orderBy .= ", $originalOrderBy DESC "; return $orderBy; }); +add_filter('glm-member-db-fields-front-list-query-params', function(){ + $queryParams = array(); + // Get all custom fields + $customFields = $this->wpdb->get_results( + "SELECT field_name,field_type + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields", + ARRAY_A + ); + foreach ( $customFields as $field ) { + switch ( $field['field_type'] ) { + case 'checkbox': + $fieldName = preg_replace( '/[ -]/', '_', strtolower( $field['field_name'] ) ); + if ( isset( $_REQUEST[$fieldName] ) ) { + $queryParams[] = "$fieldName={$_REQUEST[$fieldName]}"; + } + break; + } + } + return ( !empty( $queryParams ) ? '&'.implode( '&', $queryParams): ''); +}); add_filter('glm_custom_fields', function($attribute, $id = 0) { global $wpdb; -- 2.17.1