Created
August 24, 2022 13:09
-
-
Save geotsiokos/7a54b127c252e4347e30a2fc46cb97f4 to your computer and use it in GitHub Desktop.
This file contains 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
// Appends Affiliates URL parameter and ID in every URL, when the affiliate cookie exists | |
add_action( 'template_redirect', 'affiliates_pname_redirect' ); | |
function affiliates_pname_redirect() { | |
$pname = get_option( 'aff_pname', AFFILIATES_PNAME ); | |
if( isset( $_COOKIE[AFFILIATES_COOKIE_NAME] ) && !$_GET[$pname] ) { | |
$location = esc_url( add_query_arg( $pname, $_COOKIE[AFFILIATES_COOKIE_NAME] ) ); | |
wp_redirect( $location ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment