Skip Navigation

[Resolved] Save users search filter.

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2613393

jum

I am trying to create a save search option for the users search filter. I followed these steps below

Step 1: Created a custom post type Saved search.
Step 2: Created a Custom field Field group of search-> Search URL, Keyword
Step 3: Created Post form with custom field and taxonomy for the search form.
Step 4: Added Save search Button to the main search page.

How to proceed next to get the search URl of the particular user and pull saved details to the users.

#2613663

Hi,

Thank you for contacting us and I'd be happy to assist.

To suggest the next steps, I'll need to see how these elements are set up in the admin area.

Can you please share temporary admin login details, along with the link to the page where this search can be seen?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2614251

jum

Hi Waqar,

I have updated the details. Please have a look for guidance.

#2615409

Thank you for waiting.

Just wanted to let you know that I'm working on it and will share my further findings, shortly.

#2615745

jum

Hi Waqar,

Thanks for helping us with this feature.

Meanwhile, I am also trying to figure this out. I have provided the below js code to fetch the URL. The issue is when I do the search in the main page the URL of the search page is the same as the %postname%. How to get the search URL for this and how to retrieve the saved search?

jQuery(document).ready(function($) {
var currentURL = window.location.href;
$('[name="wpcf-search-url"]').val(currentURL);
});

Thanks in advance,

#2616061

Thank you for waiting, while I performed some tests on your website and on my own.

If your goal is to allow users to save the search they've made so that they can quickly re-use it in the future, the search URL and the URL parameters should be enough. You don't have to save the individual selection values in the custom fields you've added with the post type 'Saved searches'.

Here are the steps, that I'll recommend:

1. Instead of adding the 'Save search form' on a separate page 'Save-search', you can include it on the same page 'Research funding database' under the search form itself.
( I've already added the form under the search )

2. From this form 'Save search form', you can remove all the fields and only keep the post title field, 'Search URL' field, and the Submit button.

The user will be able to name this saved search through the title field and the custom script that you have included in the form, will automatically fill the full URL in the Search URL field.

Note: The search view was previously set to show the search results through the AJAX, i.e. without reloading the page. That is why the search parameters were not updating in the URL and the script was not working. But, now the view is set to update the search result, by updating/reloading the page and the script is working.

Additional note: If for some reason, it is an absolute requirement to save the individual search fields in the respective custom fields too, you can use the 'cred_save_data' hook to extract the search terms from the URL parameters saved in the 'Search URL' field and then save them in those individual fields too.
( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data )

I hope this helps and please let me know if you have any follow-up questions.

#2616933

jum

My issue is resolved now. Thank you!