• Resolved rockboxmedia

    (@rockboxmedia)


    Hello,

    I want to forward a parameter value to my pretty links, without specifying the key. For example, the outgoing link could be:

    http://mysite.com/?value

    This forwards to the affiliate link like this:

    http://affiliatesite.com/?somekey=&value

    I don’t want the &

    The reason for doing this is that “somekey” can vary by affiliate link, so I want to hardcode that in each pretty link, instead of passing it through.

    Is that possible?

    I can program PHP so if you tell me which file I can edit the regex or add a str_replace/preg_replace for the final & in the URL, that would work too.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author cartpauj

    (@cartpauj)

    There’s a hook for that in /app/models/PrliUtils.php

    $param_string = apply_filters('prli_redirect_params', $param_string);

    Thread Starter rockboxmedia

    (@rockboxmedia)

    OK I think I got it to work. I just need to comment out the & here, right?

    if(isset($parray[1])) {
    $param_string = (preg_match(“#\?#”, $pretty_link_url)?”&”:”?”) . $parray[1];
    }

    Then, in the pretty link, any parameter I pass after the ? simply goes at the end of the target URL without the &, right?

    Will there be any other problems if I do that?

    Thanks for your help.

    Plugin Author cartpauj

    (@cartpauj)

    You would create your own custom callback for that filter (don’t edit Pretty Link code directly).

    function my_custom_param_string_filter($string) {
      if(!empty($string)) {
        $string = substr($string, 1); //Remove the first character in the string
      }
      
      return $string;
    }
    add_filter('prli_redirect_params', 'my_custom_param_string_filter');

    Custom code works great in a plugin like My Custom Functions.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to forward parameter without &’ is closed to new replies.