Passing a setting to the redirect URL

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Passing a setting to the redirect URL

This topic contains 6 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 5 years, 6 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #11222
    MatthewFass
    MatthewFass
    Participant

    Hi

    I am attempting to follow your instructions here on how to pass additional parameters to the redirect URL: https://wp-dreams.com/knowledge-base/how-to-add-variables-to-the-redirect-to-url-or-the-show-more-url/

    // Use this to change the "redirect to url" parameter
    add_filter( 'asp_redirect_url', 'asp_add_params_to_url', 1, 10 );
    // Use this to change the "show more results url" parameter
    add_filter( 'asp_show_more_url', 'asp_add_params_to_url', 1, 10 );
    function asp_add_params_to_url( $url ) {
      // Array of param names and values
      $values = array(
        "fwp_itemtype" => "MYSETTINGHERE"
      );
      // Merge them together
      foreach ( $values as $k => $v )
        $url .= "&".$k."=".$v;
      
      return $url;
    }

    My confusion is how to pass the item_type I have selected in the settings (for example, “event”) to MYSETTINGHERE. Can you clarify.

    Many thanks.

    -Matthew
    Thinking Partners
    Red Hook, NY

    #11223
    MatthewFass
    MatthewFass
    Participant

    Here’s a screenshot, for clarity sake

    Attachments:
    You must be logged in to view attached files.
    #11225
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    The field values for checkboxes are passed along in the $_POST request variable. Each fieldset group has a unique name to prevent conflicts. The best was to find the name is by simply using the developer tools, in your case: https://i.imgur.com/esNra6o.png

    So the selected items will be in the:

    $_POST['aspf1_11']['wpcf-item_type_1']

    array.

    But the problem is that you won’t be able to add that there, as this is set only after the search is already printed on the page. The only solution is to create some kind of javascript code to change the redirect url on the FORM element.

    Best,
    Ernest Marcinko

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


    #11247
    MatthewFass
    MatthewFass
    Participant

    Okay, thanks for your reply! I will use JavaScript. But in the meantime, WHAT exactly are these instructions for?

    https://goo.gl/rsE1I1

    Wouldn’t you want parameters appended to the URLs to be dynamic depending upon what the user has selected?

    #11255
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    It’s for cases when you want to add static variables based on certian conditions (like current post ID, custom field values, etc..). This is however executed right before the plugin is printed. Dynamically changing the redirection requires javascript, as it’s triggered from the client side (browser), however PHP runs on the server side.

    Best,
    Ernest Marcinko

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


    #11270
    MatthewFass
    MatthewFass
    Participant

    Many thanks for clearing that up and keep up the great work.

    #11272
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

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


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

You must be logged in to reply to this topic.