I have a list of entries where one of the columns can contain multiple entries. If I select multiple species from a checkbox field, the filter doesn't work. I had assumed there might be a filter like 'contains' instead of like, but there doesn't seem to be. Any ideas on how I might achieve this?
Have adapted the code on the formidable site to do what I want, posting it here in case it helps anyone.https://formidableforms.com/knowledgebase/frm_where_filter/#kb-add-two-filters-combined-with-orfunction frm_search_multiple_vals( $where, $args ) {
$view_id = 472; // Replace with your View ID
$field = 15; // Replace with ID of your field
if ( !empty( $_GET['species'] ) ) {
$search = explode(', ', $_GET['species']);
if ( $args['display']->ID == $view_id && $args['where_opt'] == $field ) {
$where = "( ( fi.id = " . $field . ")";
foreach ( $search as $term ) {
$where .= " AND ( ( meta_value like '%" . $term . "%' ) )"; } $where .= " )";
return $where; } } return $where;}add_filter( 'frm_where_filter', 'frm_search_multiple_vals', 10, 2 );
Something seriously wrong with the code formatting on this forum. Edited a number of times to make it look okay, but given up.
thanks, I'm currently having a look at https://formidableforms.com/knowledgebase/frm_filter_where_val/#kb-check-each-value-from-checkbox although now run into other, unrelated problems. I hate working on sites hosted by other people…
LOL! There's nothing better than adjusting your own well-commented code and working with your own libraries! I stopped being shocked at some of the code I've inherited when taking on new clients. Sometimes the logic is baffling or simple functions are far too over engineered.
My background is enterprise development. I'm talking about very big systems where we worked in globally distributed dev teams of 50 or more, sometimes jumping into each other's code to help out. Code can never be over commented. The more details we leave behind in our code for other developers to follow, the better. This is especially true in the opensource world. I guess my biggest peeve when I take over a site is the code not being commented and sometimes the best approach is starting over and do it right.
I don't know if you like to watch HGTV, but there's a new show on called "Rico to the Rescue" that I find entertaining. I feel like that guy with some of the sites I've seen!
Haha, I'm that guy, I think you'd hate to work on some of my sites, I just want to get it done! My current issue is no access to the server. Annoying as it's refusing to upload CSV files and I can't seem to find a reason for it.
Sounds like mime-type.
Please login or Register to submit your answer