Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Clear form after submission
This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko 10 months ago.
- AuthorPosts
- May 23, 2022 at 3:31 pm #37836
Hello,
I have a search form at home. On the search results page I have the same form again, but I would like the form to be clean.
That is, I would like it so that after I click on the search button, i go to search results page, and the form there does not keep track of the search done but it’s clean.
I cannot find this option.Thanks
May 24, 2022 at 3:12 pm #37841Hi,
Well, there is no option to do that, the plugin will automatically fetch the posted options. It might be however possible via a minor custom code snippet.
Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
Best,add_filter('asp_shortcode_search_options', 'asp_reset_options_on_results_page', 10, 1); function asp_reset_options_on_results_page($settings) { unset($_POST['p_asp_data']); unset($_GET['p_asp_data']); return $settings(); }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 24, 2022 at 4:16 pm #37845hello,
I think there are some parentheses that don’t fit in
return $settings();
However removing the parentheses
return $settings;
it works but only for filters, I would like the main search field to be clean too.Thanks again
May 25, 2022 at 1:53 pm #37854You are correct, that was my mistake.
To clear the input field, you need an additional code as well:
Best,add_filter("asp_print_search_query", "asp_change_print_search_query", 10, 2); function asp_change_print_search_query($query, $search_id) { return ''; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 25, 2022 at 2:30 pm #37857Everything works fine!
Thanks
May 25, 2022 at 2:34 pm #37858You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.