*/
require_once GLM_MEMBERS_FIELDS_PLUGIN_SETUP_PATH.'/permissions.php';
+/*
+ * Adding filter for updating the shortcode attributes for the member list shortcode
+ * This has to be done before the frontHooks are run.
+ */
+add_filter( 'glm-custom-fields-shortcodes', function( $shortCodes ){
+ global $wpdb;
+ if ( !is_array( $shortCodes ) || empty( $shortCodes ) ) {
+ return $shortCodes;
+ }
+ // Get all custom fields
+ $customFields = $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 the attributes array exists in glm-members-list and the one for the custome
+ // field name has not been set yet, then set it.
+ if ( isset( $shortCodes['glm-members-list']['attributes'] )
+ && !isset( $shortCodes['glm-members-list']['attributes'][$fieldName] )
+ ) {
+ $shortCodes['glm-members-list']['attributes'][$fieldName] = false;
+ }
+ break;
+ }
+ }
+ return $shortCodes;
+ },
+ 10,
+ 1
+);
2
);
-add_filter('glm-member-db-front-search-query', function( $queryParts ) {
- //$queryParts = array();
+add_filter( 'glm-member-db-front-search-query', function( $queryParts ) {
// Get all custom fields
$customFields = $this->wpdb->get_results(
"SELECT *
}
return $queryParts;
});
-add_filter('glm-member-db-fields-front-list-query-params', function( $query ){
+add_filter( 'glm-member-db-front-search-request', function( $actionData ) {
+ global $wpdb;
+ // Get all custom fields
+ $customFields = $wpdb->get_results(
+ "SELECT *
+ FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields",
+ ARRAY_A
+ );
+ if ( isset( $customFields ) && count( $customFields ) > 0 ) {
+ foreach ( $customFields as $key => $field ) {
+ // convert name to lower case and replace spaces with _
+ $field_name = preg_replace( '/[ -]/', '_', strtolower( $field['field_name'] ) );
+ if ( isset( $actionData['request'][$field_name] ) ) {
+ $_REQUEST[$field_name] = $actionData['request'][$field_name];
+ }
+ }
+ }
+ return $actionData;
+}, 10, 1);
+add_filter( 'glm-member-db-fields-front-list-query-params', function( $query ){
$queryParams = array();
// Get all custom fields
$customFields = $this->wpdb->get_results(
},
10,
2
-);
\ No newline at end of file
+);