Appending URL parameters not working with existing hook
-
Hi there,
I am trying to append URL parameters (for affiliate purposes) dynamically to certain links on my website. I followed the tips provided in this post, however have been unlucky. When I click the call to action button in the page linked here, “Try for free”, it no longer redirects but the URL looks like so: https://wttdev.wpengine.com/out/Array (I’m testing this in a dev environment right now, but just showing you for reference). It seems odd that this would not work with an array, given that the hook was set up for an array. What am I doing wrong?
Here is my code, I created a separate plugin to handle this code and can confirm that the plugin is active in dev environment, where I am trying this all out.
// affiliate-links.php
<?php /* Plugin Name: Affiliate Links Plugin Description: Adding URL param to Wix-only affiliate links Version: 1.0 Author: [email protected] License: GPL2 */ // Adding filter hook from Pretty Links Plugin to our Wix CTA links function append_to_target_url($pretty_link_array) { $wix_post_id = '&s3=' . $post->ID; $pretty_link_array['url'] = $pretty_link_array['url'] . $wix_post_id; return $pretty_link_array; } add_filter('prli_target_url', 'append_to_target_url');
// PrliUtils.php
// This is where the magic happens! public function track_link($slug,$values) { global $wpdb, $prli_click, $prli_options, $prli_link, $plp_update; $query = "SELECT * FROM ".$prli_link->table_name." WHERE slug='$slug' LIMIT 1"; $pretty_link = $wpdb->get_row($query); $pretty_link_array = array( 'url' => $pretty_link->url, 'link_id' => $pretty_link->id, 'redirect_type' => $pretty_link->redirect_type ); $pretty_link_target = apply_filters('prli_target_url', $pretty_link_array); $prli_edition = ucwords(preg_replace('/-/', ' ', PRLI_EDITION)); // Error out when url is blank if($pretty_link->redirect_type != 'pixel' && (!isset($pretty_link_target['url']) || empty($pretty_link_target['url']))) { return false; } $pretty_link_url = $pretty_link_target; $track_me = apply_filters('prli_track_link', $pretty_link->track_me);
Thanks in advance for your help!
The page I need help with: [log in to see the link]
- The topic ‘Appending URL parameters not working with existing hook’ is closed to new replies.