Populate user input into Confirmation Redirect URL

I feel like this should be simple, but I’m struggling.

I want to pass the user input of a field into the confirmation redirect url for a search box.

I have created a simple search form using the WPSunshine add on, and want the submit button to redirect to the search page with the search term the user has typed in

example url: https://lurnex.net/?s=[user_search_term]

What do I need to use to capture the user input?

My form can be found here: https://lurnex.net/search-form-page/

Thanks!!

Hi Steven,

You can also use jQuery to pass the user input to the button URL. So when someone types and clicks on the button, it will open the search result page with the user input as the search query.

The following code can be used in the Child theme JavaScript file, or you can try the “Simple Custom CSS and JS” plugin.

<script>
  jQuery(document).ready(function ($) {
    var searchTerm = $("form .gfield input#input_7_1").val();

    $("form .gform_footer input.gform_button").click(function () {
      window.location.href = "https://lurnex.net/?s=" + searchTerm;
    });
  });
</script>

Preview:

Plugin link:

Give it a try, and let me know how that goes! :smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.