Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › form action to external website (no ajax results needed)
This topic contains 4 replies, has 2 voices, and was last updated by soliddop 1 year, 1 month ago.
- AuthorPosts
- February 15, 2022 at 9:41 pm #36753
Hi, Can I create a search form with form action to an external website and with “q” search variable? Basically alongside with many custom-post search (that I already succeded) I need to create a search form with the same design that I already use but to get this form search string to an external website (without ajax results at all, just a simple form). Is this possible?
Any help would appriciated,
KarlsPS: I found some settings under logic & behavior but the redirect to custom url is remain locally and just put my url after it, like:
https://mywebsite.com/https:/externalwebsite.com/search?q=samplestring&asp_active=1&p_asid=7&p_asp_data=1&filters_initial=1&filters_changed=0&qtranslate_lang=0¤t_page_id=143My desired search url is https://externalwebsite.com/search?q=samplestring
February 16, 2022 at 9:26 am #36756Hi,
Sure – not via an option, but a small custom code snippet. This should do the trick:
Best,add_filter('asp_redirect_url', 'custom_asp_redirect_url', 10, 1); function custom_asp_redirect_url($url) { return "https://externalwebsite.com/search?q={phrase}"; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 16, 2022 at 9:43 am #36757Hi,
Thanks for the quick reply and snippet (inserted into child-theme/funcitons.php) but I’m still getting the above mentioned local url prefix:
https://mywebsite.com/https:/externalwebsite.com/search?q=samplestring&asp_active=1&p_asid=7&p_asp_data=1&filters_initial=1&filters_changed=0&qtranslate_lang=0¤t_page_id=143alongside with many url string variables.
Do I need to change something else in the widget settings?February 16, 2022 at 3:53 pm #36763Maybe that one will not work, I can’t recall if the javascript does validate agains the current domain. Maybe instead of the previous code, try this one:
add_action('wp_footer', 'asp_add_footer_script', 9999); function asp_add_footer_script() { ?> <script> (function($){ WPD.Hooks.addFilter('asp_redirect_url', function(url, id, instance){ return "https://externalwebsite.com/search?q=" + $('.asp_m_' + id + '_' + instance).find('input.orig').val(); }, 10); }(WPD.dom)); </script> <?php }
It is a bit more complicated, but it changes the URL right before the submission, so it should be more likely to work.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 16, 2022 at 6:25 pm #36780Thank you for your support on this !
- AuthorPosts
You must be logged in to reply to this topic.