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

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

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #11222
    MatthewFassMatthewFass
    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/

    [php]// 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;
    }[/php]

    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
    MatthewFassMatthewFass
    Participant

    Here’s a screenshot, for clarity sake

    #11225
    Ernest MarcinkoErnest 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:

    [code]$_POST[‘aspf1_11’][‘wpcf-item_type_1’][/code]

    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.

    #11247
    MatthewFassMatthewFass
    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 MarcinkoErnest 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.

    #11270
    MatthewFassMatthewFass
    Participant

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

    #11272
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

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