WP Login redirecting to previously visited page
-
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; } ?>
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 “https://www.mydomain.com/wp-login?location=%2Fsubfolder%2Fmypage.php”
How can I get that url to redirect after successful login to https://www.mydomain.com/subfolder/mypage.php
??????ANY THOUGHTS????
- The topic ‘WP Login redirecting to previously visited page’ is closed to new replies.