Forked from mauriciogofas/gofas_custom_AffiliateClickthru.php
Created
February 8, 2019 14:51
-
-
Save mhrubel/0fb7d1103f745498509eb1ac774b0366 to your computer and use it in GitHub Desktop.
WHMCS Custom affiliates redirects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom Affliates Redirects | |
* © 2017 gofas.net | |
* | |
*/ | |
add_hook('AffiliateClickthru', 1, function($vars) { | |
$affiliate_id = (int)$vars['affiliateId']; | |
$destination = (string)'https://example.com'; // default destination after affiliate link click | |
if ( $_REQUEST['page'] ) { // page is the parameter name | |
$destination = (string)$_REQUEST['page']; | |
header( "Location: $destination" ); | |
exit; | |
} | |
if ( $vars['affiliateId'] === 1 ) { // ID of affiliate | |
$destination = (string)'https://otherexample.com'; | |
header( "Location: $destination" ); | |
exit; | |
} | |
// default destination if not page parameter and not affiliate ID | |
else { | |
header( "Location: $destination" ); | |
exit; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment