I’m trying to set my funnel up to allow anyone to use an affiliate ID in the URL to get credit for a referral on an external site. The ID will not be a predefined value in the database.
Instead of me sending them to mysite.com, I would send them to mysite.com/?id=MyID.
When they click the button to join the opportunity I’m promoting, I want it to take them to opportunitysite.com/MyID.
As an incentive for them to sign up, I’ll provide my funnel for them to use to promote the same opportunity, but without building them another funnel.
So they can send their leads to mysite.com/?id=TheirID. When their lead clicks the button to join the opportunity, it takes them to opportunitysite.com/TheirID.
I tried the following code in functions.php, but it broke my page. I think this is a step in the right direction. Can anyone help me out? And where at in functions.php would be better to put it?
function themeslug_query_vars( $qvars ) {
// add ‘id’ to the recognised query string vars
$qvars[] =
return $qvars;
}
add_filter( ‘query_vars’, ‘themeslug_query_vars’ );
function themeslug_init() {
// get the ID
$aff_id = get_query_var(‘id’);
// if present, do the redirect
if isset( $aff_id ) {
// redirect
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location:
}
}
add_action(‘init’, ‘themeslug_init’);