Add search dropdowns for meta_key(s)?
-
Hi,
This is a rather complex question ??
I’m using Relevanssi the overall site search, and I am also using the Paid Membership Pro plugin (which I see Relevanssi supports relevanssi_post_ok.) The PMPro plugin has its own search form, and it returns full text search results, like Relevanssi.
In PMPro, I’ve added custom fields (i.e. user_country and user_state) for member profiles, and that added meta_key(s), i.e. user_country and user_state, stored in wp_usermeta. I can search on a word, including words whch occur the meta_key(s) (i.e. Arizona), using the default PMPro search form, and those sarch results work fine.
But what I need to do is have dropdowns that let me select meta_key(s) to search on, like in the image https://ibb.co/GPCcZtX
Do you have some ideas of where I would start to build a search form with And/Or drop downs for those meta_keys and meta_values?
Would I need a search form that builds an SQL query? Or filter the results after?
This is the default PMPro search form:
<form role="search" method="post" class="<?php echo pmpro_get_element_class( 'pmpro_member_directory_search search-form', 'directory_search' ); ?>"> <label> <span class="screen-reader-text"><?php _e('Search for:','pmpro-member-directory'); ?></span> <input type="search" class="search-field" placeholder="<?php _e('Search Directory','pmpro-member-directory'); ?>" name="ps" value="<?php if(!empty($_REQUEST['ps'])) echo stripslashes( esc_attr($_REQUEST['ps']) );?>" title="<?php _e('Search Directory','pmpro-member-directory'); ?>" /> <input type="hidden" name="pn" value="1" /> <input type="hidden" name="limit" value="<?php echo esc_attr($limit);?>" /> </label> <input type="submit" class="search-submit" value="<?php _e('Search Members','pmpro-member-directory'); ?>"> </form>
- The topic ‘Add search dropdowns for meta_key(s)?’ is closed to new replies.