Forums Forums Search & Filter Pro Dynamically update Results URL

  • This topic has 3 replies, 3 voices, and was last updated 8 months ago by Anonymous.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #219187

    Hi,

    Is there a hook/filter which I can use in order to dynamically update the Results URL of a form?

    Each ‘shop’ on my website displays a users products via the form. However, each shop is obviously at a different url:

    example.com/shop/amazing-lamps
    example.com/shop/johns-tables

    Currently it’s set to: example.com/shop/amazing-lamps
    If I do a form search on: example.com/shop/johns-tables it will redirect be back to the above url instead for the results.

    Therefore the URL needs changing on load. I know this is not a normal use-case but if I have a hook/filter to pass data to, to change that results url, that’ll work for me.

    Anonymous
    #219188

    I realised that the results_url is simply a piece of post meta, meaning I could just:

    Grab the form ID
    Provide the meta key to update
    Build a new url base

    if ( $sfid == 29 ) {

    // Dynamically update the search-and-filter results url.
    $meta_key = ‘_search-filter-results-url’;
    $results_url = home_url() . ‘/’ . ‘shop/’ . $store_user->data->user_nicename;

    update_post_meta( $sfid, $meta_key, $results_url );
    }

    This works great, however just thinking if it’s suitable. If 10 people load a different shop url all at once, that post meta is going to rapidly change.

    Anyway just providing my solution so far and open to thoughts ideas if needed.

    Trevor
    #219226
    Anonymous
    #288374

    Provided by Stefan
    In case someone else runs into this problem, this works to add the form to multiple pages:

    function my_set_sf_resultsURL( $url, $sfid) {
    $url = get_permalink();
    return $url;

    }
    add_filter( ‘sf_results_url’, ‘my_set_sf_resultsURL’, 10, 2 );

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