Last active
January 20, 2020 13:28
-
-
Save mauriciogofas/8b3c836961fccbe2903894607dc7b051 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