From: Steve Sutton Date: Thu, 13 Apr 2017 20:11:26 +0000 (-0400) Subject: Adding filter to create the get parameters for custom fields. X-Git-Tag: v1.0.0^2~18 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=822aa4da2cba5b391e41f051c75fb41720068977;p=WP-Plugins%2Fglm-member-db-fields.git 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. --- 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;