This support ticket is created 6 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I have a page with a search form.
The results get output on a different page.
TWO things aren't happening the way I want.
a) If i leave the field blank and hit SUBMIT, it lists ALL of the custom posts of that type.
It should return an error message ("You must enter a search code")
b) Every post title for the custom post type consists of a unique 10 letter alpha-numeric code.
I want the search to only return EXACT MATCH results.
However, currently, if the user manages to guess two or three letters, the search shows a result for the matching post.
Basically, I ONLY want people who know the exact 10 letter alpha-numeric code of the post title to be able to pull up the results.
THANK YOU!!
That mostly works....
It now requires a perfect match if I enter something into the text input field...
BUT
If I just hit Search (i.e. with the text input field left blank) it returns a full list of all posts 🙁
I'd like it to generate a (WPML translatable) error message "You must enter a search code".
Now, add following code to your view's filter section - just AFTER this line - [wpv-filter-start hide="false"]:
[wpv-conditional if="( '[wpv-search-term name='wpv_post_search']' eq '' )"]
[wpml-string context="wpv-views"]You must enter a search code.[/wpml-string]
[/wpv-conditional]
The only problem now is the text "You must enter a search code."
I did as you suggested but it shows up permanently. Even after a successful search.
Full filter code:
[wpv-filter-start hide="false"]
[wpv-conditional if="( '[wpv-search-term name='wpv_post_search']' eq '' )"]
[wpml-string context="wpv-views"]You must enter a search code.[/wpml-string]
[/wpv-conditional]
[wpv-filter-controls]
<div class="form-group">[wpv-filter-search-box placeholder="Enter Shipment Code (10 characters)" output="bootstrap"]</div>
[wpv-filter-submit class="my-button" name="Get Current Shipping Status" output="bootstrap"]
<br><br>
[/wpv-filter-controls]
[wpv-filter-end]
[wpv-conditional if="( '[wpv-search-term param='wpv_post_search']' eq '' )"]
[wpml-string context="wpv-views"]You must enter a search code.[/wpml-string]
[/wpv-conditional]
I hope all sorted - please let me know your feedback 🙂
Now, when i enter something in the text input field the message doesn't show with the results.
BUT..
The first time the field is displayed, the text is on the screen.
We only want this to appear as an error message AFTER the user forgets to input a code.
Ahh, you want that way to work. Please use following code:
[wpv-conditional if="( '[wpv-search-term param='wpv_post_search']' eq '' ) AND ( '[wpv-search-term param='wpv_view_count']' ne '' )"]
[wpml-string context="wpv-views"]You must enter a search code.[/wpml-string]
[/wpv-conditional]
So now the error message doesn't appear the first time the form loads - Good.
But it doesn't appear if I submit the form with an empty text input box - Bad.
[wpv-filter-start hide="false"]
[wpv-conditional if="( '[wpv-search-term param='wpv_post_search']' eq '' ) AND ( '[wpv-search-term param='wpv_view_count']' ne '' )"]
[wpml-string context="wpv-views"]You must enter a search code.[/wpml-string]
[/wpv-conditional]
[wpv-filter-controls]
<div class="form-group">[wpv-filter-search-box placeholder="Enter Shipment Code (10 characters)" output="bootstrap"]</div>
[wpv-filter-submit class="my-button" name="Get Current Shipping Status" output="bootstrap"]
<br><br>
[/wpv-filter-controls]
[wpv-filter-end]