Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter BarbaraCee

    (@barbaracee)

    The issue for that peculiar error was actually, I erased a critical piece of code in PrliUtils.php, as in:

    $pretty_link_url = $pretty_link_target;

    should actually be:

    $pretty_link_url = $pretty_link_target['url']; as you have it originally written in your plugin *face palm*

    However, now that I have put that back in, the redirect is working as expected however I am completely unable still to append any parameters. I thought at one point the issue was that (1) post ID was not available as here I am calling it outside the loop and/or (2) the post ID was not available yet as the plugin is running too quickly, and hence I have plopped that into the template_redirect hook. Though, even the first bit of the parameter of &s3= is not being appended so I really am at a loss here.

    Your help would be appreciated!

    P.S. here is what my plugin looks like now:

    <?php
    /*
        Plugin Name: Affiliate Links Plugin
        Description: Adding URL param to Wix-only affiliate links
        Version: 1.0
        Author: [email protected]
        License: GPL2
    */
    add_action('template_redirect', function() {
      global $wp_query;
      $postID = $wp_query->get_queried_object_id();
       // Adding filter hook from Pretty Links Plugin to our Wix CTA links
      function append_to_target_url($pretty_link_array) {
        $wix_id = '&s3=' . $postID;
        $pretty_link_array['url'] = $pretty_link_array['url'] . $wix_id;
        return $pretty_link_array;
      }
      add_filter('prli_target_url', 'append_to_target_url');
    });
    
    • This reply was modified 5 years, 1 month ago by BarbaraCee.
    Thread Starter BarbaraCee

    (@barbaracee)

    Figured it out!

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