简体   繁体   中英

How to redirect wordpress logged users in another page?

I need to redirect all wordpress users that visit a certain page to another page? how can I do?

Assuming you mean logged in users there are two ways to go about this :

<?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);
    }
?>

If it is a fixed page however, and you want ALL traffic, not just registered users to go, then a redirect in the .htaccess file, or IIS rewrites would be another solution. Check out https://www.htaccessredirect.net / which can give you easy redirect solutions to put in your htaccess.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM