php 基于查询参数的高级Wordpress COOKIE重定向
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 基于查询参数的高级Wordpress COOKIE重定向相关的知识,希望对你有一定的参考价值。
function customertitle_cookie() {
$customertitle = 'accountOrigin';
$titleid = $_GET['accountOrigin'];
if (isset($titleid)) {
setcookie( $customertitle, $titleid, time() + (86400 * 30), "/");
}
}
add_action( 'init', 'customertitle_cookie' );
function redirect_to_custom_member_site() {
global $post;
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$customertitle = $_COOKIE['accountOrigin'];
if (isset($customertitle) && $customertitle == 'GP' && strpos($url,'nytta-noje-medlem') !== false) {
$url = 'http://medlem.gp.se' . $_SERVER['REQUEST_URI'];
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'HN' && strpos($url,'nytta-noje-medlem') !== false) {
$url = 'http://medlem.hn.se' . $_SERVER['REQUEST_URI'];
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'HP' && strpos($url,'nytta-noje-medlem') !== false) {
$url = 'http://medlem.hallandsposten.se' . $_SERVER['REQUEST_URI'];
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'BN' && strpos($url,'nytta-noje-medlem') !== false) {
$url = 'http://medlem.bohuslaningen.se' . $_SERVER['REQUEST_URI'];
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'TT' && strpos($url,'nytta-noje-medlem') !== false) {
$url = 'http://medlem.ttela.se' . $_SERVER['REQUEST_URI'];
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'ST' && strpos($url,'nytta-noje-medlem') !== false) {
$url = 'http://medlem.stromstadstidning.se' . $_SERVER['REQUEST_URI'];
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'GP' && strpos($url,'mer-fran-nytta-noje') !== false) {
$url = 'http://medlem.gp.se';
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'HN' && strpos($url,'mer-fran-nytta-noje') !== false) {
$url = 'http://medlem.hn.se';
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'HP' && strpos($url,'mer-fran-nytta-noje') !== false) {
$url = 'http://medlem.hallandsposten.se';
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'BN' && strpos($url,'mer-fran-nytta-noje') !== false) {
$url = 'http://medlem.bohuslaningen.se';
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'TT' && strpos($url,'mer-fran-nytta-noje') !== false) {
$url = 'http://medlem.ttela.se';
wp_redirect( $url );
exit();
}
else if (isset($customertitle) && $customertitle == 'ST' && strpos($url,'mer-fran-nytta-noje') !== false) {
$url = 'http://medlem.stromstadstidning.se';
wp_redirect( $url );
exit();
}
}
add_action( 'template_redirect', 'redirect_to_custom_member_site' );
以上是关于php 基于查询参数的高级Wordpress COOKIE重定向的主要内容,如果未能解决你的问题,请参考以下文章
在 Wordpress 中使用 JOIN 进行高级 MySQL 查询