form action to external website (no ajax results needed)

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 soliddop 1 year, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #36753
    soliddop
    soliddop
    Participant

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

    PS: 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&current_page_id=143

    My desired search url is https://externalwebsite.com/search?q=samplestring

    • This topic was modified 1 year, 1 month ago by soliddop .
    #36756
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Sure – not via an option, but a small custom code snippet. This should do the trick:

    add_filter('asp_redirect_url', 'custom_asp_redirect_url', 10, 1);
    function custom_asp_redirect_url($url) {
    	return "https://externalwebsite.com/search?q={phrase}";
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #36757
    soliddop
    soliddop
    Participant

    Hi,
    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&current_page_id=143

    alongside with many url string variables.
    Do I need to change something else in the widget settings?

    #36763
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Maybe 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 :)


    #36780
    soliddop
    soliddop
    Participant

    Thank you for your support on this !

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.