簡體   English   中英

如何在另一個頁面中重定向 wordpress 登錄用戶?

[英]How to redirect wordpress logged users in another page?

我需要將訪問某個頁面的所有 wordpress 用戶重定向到另一個頁面嗎? 我能怎么做?

假設您的意思是登錄用戶,有兩種方法可以解決這個問題:

<?php
    //All Users
    if (is_user_logged_in()) {
        //Do Redirect in your preferred method eg
        header('Location: ' . $fullUrlToGoTo);
    }

    //Users who may be a of certain type eg admins
    if (current_user_can('administrator')) {
        //Do Redirect in your preferred method eg
        header('Location: ' . $fullUrlToGoTo);
    }
?>

但是,如果它是一個固定頁面,並且您希望所有流量,而不僅僅是注冊用戶,那么 .htaccess 文件中的重定向或 IIS 重寫將是另一種解決方案。 查看https://www.htaccessredirect.net/ ,它可以為您提供簡單的重定向解決方案以放入您的 htaccess。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM