I have a WP install on a single domain and some custom PHP pages not part of WP but in the root folder. When the pages are accessed directly I want it to check if the user is logged in or not, which I currently have..... <?php require('../wp-load.php'); get_header(); if ( is_user_logged_in() ) { echo "Welcome, Registered User"; } else { header("Location:../wp-login.php?location=" . urlencode($_SERVER['REQUEST_URI'])); exit; } ?> PHP: This function is on the page I want protected and it works. What it does is checks if the end user viewing the page is logged in. If the end user is logged in the text, "Welcome, Registered User", is shown and then the page contents. If not authenticated, the page redirects to the login page and the url displays "http://www.mydomain.com/wp-login?location=%2Fsubfolder%2Fmypage.php" How can I get that url to redirect after successful login to http://www.mydomain.com/subfolder/mypage.php ??????ANY THOUGHTS????
The first option is to use Peter's Login Redirect plugin that will do the trick... The second option is that You will need to edit the wordpress core files which is a bad idea... but if you really need that stuff so open wp-login.php and find : } else { $redirect_to = admin_url(); } Code (markup): and replace with : } else { $redirect_to = $_SERVER[HTTP_REFERER]; } Code (markup): Goodluck