我有向页面添加cookie的代码,非常简单:
function setup_user() {
if (is_page(21)) {
setcookie("user_type", "advanced", time()+157680000);
}
}
add_action( \'get_header\', \'setup_user\');
如果用户转到某个页面,则他们是高级用户,不需要查看基本帮助项目。所以现在我想在一些页面上隐藏一些内容。我目前使用Quotes插件来管理应该显示/隐藏的内容。我知道我可以添加条件逻辑:
if(!isset($_COOKIE["user_type"])) {
// then the content should not show.
}
如何检查该cookie,并基于它显示/隐藏网站任何页面上的内容?