This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Clear form after submission

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Clear form after submission

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #37836
    spinoWebspinoWeb
    Participant

    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

    #37841
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    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.

    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();
    }
    #37845
    spinoWebspinoWeb
    Participant

    hello,
    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

    #37854
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You are correct, that was my mistake.

    To clear the input field, you need an additional code as well:

    add_filter("asp_print_search_query", "asp_change_print_search_query", 10, 2);
    function asp_change_print_search_query($query, $search_id) {
      return '';
    }
    #37857
    spinoWebspinoWeb
    Participant

    Everything works fine!

    Thanks

    #37858
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.