I have a field that is "single line" but right now only contains numbers (it may be alphanumeric in the future). I want a search that works with partial matches. I've selected the "like" operator, but that isn't working.
The problem seems to be that the value for this field is 7 or 8 digits long. But the string I'm entering into the search is longer. It still contains those 7 or 8, but has 5 additional at the front.
For example:
ID Number Value - 1234567
My Search Query - 045321234567
Results: None
The "like" operator doesn't recognize that query as containing the partial value.
Is there a functions or javascript solution to this that you know offhand? Something that chopped off the first few digits before submitting (or even an interim form) would be great.
The reason I have to do it this way is because we're scanning an ID card and there is extra data prepended to everyone's ID number. In the system it'll be 7 digits, but on the card it'll be 12 (those first 5 not mattering).
Hello,
There isn't such kind of features within Toolset plugins, it needs custom codes, here are my suggestion:
1) When user submit the custom search form, you can use Views filter hook "wpv_filter_query" to trigger a custom PHP function:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
2) In this PHP function, apply your "partial matches":
https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters
For your reference.