Custom Search Form

By: Sean Samford | Asked: 10/27/2022
ForumsCategory: How-toCustom Search Form
Sean Samford asked 2 years ago
I feel like I have followed the directions here How to Create a Custom Search Form in WordPress - Formidable Forms but I am not getting the view to sort on my entry. I feel like there is some thing wrong with the redirect to URL string. any help appreciated. 
Rob LeVineRob LeVine replied 2 years ago

You've set the "Sort Entries" value on the view?

4 Answers
Sean Samford answered 2 years ago
Yes, screen shot of the filter view attached.  My on submit string looks like this. https://techtransfer.ce.ufl.edu/pilot-escort-certification-look-up?last_name=[102 sanitize_url=1]&pilot_escort_certification_number=[104 sanitize_url=1] when I put in a last name like Bates, i would expect my view to shrink to only entries with a last name \"like\" Bates. The view does not change at all. but the URL changes to  Pilot Escort Certification Lookup – Transportation Technology Transfer (T2) Center (https://techtransfer.ce.ufl.edu/pilot-escort-certification-look-up/?last_name=Bates&pilot_escort_certification_number=ufl.edu) This is meant to be a quick check for user being certified or how long till certificate expires. Or who is associated with a particular certification number.   
Sean Samford replied 2 years ago

well it won't let me insert the image. but yes my filters are set. Last Name like [get param=last-name] OR Pilot Escort Certification Number is equal to [get param=pilot_escort_certification_number} AND Expiration date greater than NOW

Rob LeVineRob LeVine replied 2 years ago

The screenshot did not come through (displays as a broken link). Also, this is not sorting, this is filtering. So my guess is that in your filtering you're filtering value should be something like the following, but isn't. Last Name is equal to [get param="last_name"]

Rob LeVineRob LeVine replied 2 years ago

There it is. It's last_name, rather than last-name. Also, put it in quotes to make sure.

Sean Samford answered 2 years ago
Last Name like [get param=last_name] OR Pilot Escort Certification Number is equal to [get param=pilot_escort_certification_number} AND Expiration date greater than NOW   It is underscore on the site, tried adding quotes    Last Name like [get param="last_name"] OR Pilot Escort Certification Number is equal to [get param="pilot_escort_certification_number"] AND Expiration date greater than NOW same results
Rob LeVineRob LeVine replied 2 years ago

Please click the Fliter Entries link in the view, take a screenshot of it and use something like https://paste.pics/ to share the picture.

Sean Samford answered 2 years ago
https://paste.pics/f2966ca5597029c6680fed69089c0c98
Rob LeVineRob LeVine replied 2 years ago

This is less than fun trying to debug like this, but I can keep trying. For giggles, remove all filters except for the last name and put the double quotes around last_name and see if that works.

Sean Samford answered 2 years ago
Holy smokes that worked as expected.
Sean Samford replied 2 years ago

So it is the expiration date that is messing it up.

Sean Samford replied 2 years ago

I don't know it is working fine with both Last Name and Pilot Escort Certification Number as you said in double quotes, but no matter what I do with NOW [] '' "" not enclosing deals at all it just stops working.

Thank you so much for you assistance. If you get an idea that might let me filter out expired certs drop it in here. I am going to keep trying various combos. Maybe try with a hard date rather than NOW

Rob LeVineRob LeVine replied 2 years ago

As much as I hate to yell BUG from the mountaintops, I've personally had no luck with NOW in the filters. One thing to try to prove that NOW is the problem is to use "2022-10-27" instead of NOW and see if that works. Also, is it possible your date column is a string rather than an actual date? Finally, I wholeheartedly recommend using Datatables (or WPDatatables), which not only allows to display nice, sortable tables, it comes with its own filters that don't require a page refresh.

Sean Samford replied 2 years ago

I will futz with it some more, can't remember if I put the " " around the date but I did try to put a date and got the no filter result.
I wonder if TODAY would work or is that not even a thing?

I will look at WPDatatables. Thanks again so much for your time today.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right