Skip to content

Instantly share code, notes, and snippets.

@infoscigeek
Last active March 13, 2017 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infoscigeek/cf96f8f45efb50bea2670baa626c2d17 to your computer and use it in GitHub Desktop.
Save infoscigeek/cf96f8f45efb50bea2670baa626c2d17 to your computer and use it in GitHub Desktop.
Affiliate Code
<?php
if (!session_id()) {
session_start();
}
//read variables from the URL
function add_query_vars($aVars) {
$aVars[] = "type"; // represents the name of the affiliate
$aVars[] = "lawyer";
$aVars[] = "city";
return $aVars;
}
if(isset($wp_query->query_vars['type'])) {
$type = urldecode($wp_query->query_vars['type']);
}
if(isset($wp_query->query_vars['lawyer'])) {
$lawyer = urldecode($wp_query->query_vars['lawyer']);
}
if(isset($wp_query->query_vars['city'])) {
$city = urldecode($wp_query->query_vars['city']);
}
add_filter('query_vars', 'add_query_vars');
//set the session variable
if (isset($_GET['type'])) {
$_SESSION['type'] = $_GET['type'];
}
if (isset($_GET['lawyer'])) {
$_SESSION['lawyer'] = $_GET['lawyer'];
}
if (isset($_GET['city'])) {
$_SESSION['city'] = $_GET['city'];
}
session_write_close();
?>
<?php
if (!session_id()) {
session_start();
}
//read variables from the URL
function add_query_vars($aVars) {
$aVars[] = "group"; // represents the name of the affiliate
return $aVars;
}
if(isset($wp_query->query_vars['group'])) {
$group = urldecode($wp_query->query_vars['group']);
}
add_filter('query_vars', 'add_query_vars');
//set the session variable
if (isset($_GET['group'])) {
$_SESSION['group'] = $_GET['group'];
}
session_write_close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment