trying to watch for a specific url on the site, and based on that add a string to the url then redirect. I'm searching the substring '/product/' so it needs to be dynamic~ish (wordpress multisite, needs to work on all sites.
Tried this in functions.php.. not sure how/when to call it.
function fancy_redirect() {
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if ( (strpos($actual_link, '/product/') !== false) && (strpos($actual_link, '?start_customizing=yes') === false)) {
header('Location: '. $actual_link . '?start_customizing=yes');
}
}
Also tried it in javascript, this runs in console but not when live.
window.onload = function() {
if(location.href.search("/product/") !== -1 && location.href.search("/?start_customizing=yes") === -1) {
window.location = (location.href + "?start_customizing=yes");
}
}