Users to the site can register and log in and access a special page members.php, which is the home page of their account.

But if they leave the site and come back (provided they are still logged in) they need to be landing on members.php and not my regular home page.

Now everyone, logged in as well as logged out, folks land on the index.php page of my site.

How to make the above possible?

2 Answers
2

Add this piece of code to your theme’s functions.php file:

<?php 
    if (is_user_logged_in() && !is_page('YOUR PAGE SLUG') && empty($_SERVER['HTTP_REFERER'])) { 
        wp_safe_redirect( site_url('/members.php')); 
        exit;
    } 
?>

Assuming that your members.php is located at http://example.com/members.php. This will redirect any logged in users to that page.

Leave a Reply

Your email address will not be published. Required fields are marked *