/    Sign up×
Community /Pin to ProfileBookmark

Dynamic URL in WordPress

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: https://www.opportunitysite.com/” . $aff_id);
}
}
add_action(‘init’, ‘themeslug_init’);

to post a comment
Web Hosting

4 Comments(s)

Copy linkTweet thisAlerts:
@virtualprofitlifeauthorMar 17.2021 — Can’t seem to get the code function to work on my phone.
Copy linkTweet thisAlerts:
@shahzadjamilApr 24.2021 — On your WordPress dashboard, go to “If-So → Add New Trigger”

Click on “Select a condition” and select “Dynamic Link“.

Type in a query string name. It can be a word, phrase, or one letter.

In the content field, set the content to be displayed if visitors arrive via the dynamic link

In the default content field, set content to be displayed if the condition is not met (optional, can be left blank).

Press “Publish” and paste the shortcode generated by If-So on your website.
Copy linkTweet thisAlerts:
@VITSUSAApr 27.2021 — I agree with shahzadjamil, this is a good solution.
Copy linkTweet thisAlerts:
@carbikemoversindiaJun 15.2021 — Thanks for the information
×

Success!

Help @virtualprofitlife spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...