Redirect – if not logged in, on front page, or in category?
-
I have a website for a client – it’s very protective of the content, and so has an external login system to the WordPress site.
Now, I have it so anyone who isn’t logged in is redirected to the home page when trying to view the other pages. However, I need to open up the posts from one article, so they are not redirected when viewing the post.
Also, when viewing the category itself, the user is redirected outside the WordPress site, just to be sent back again when clicking on a post there. Essentially, the category page is external to the WordPress site (don’t ask me why).
So, in the end, I need to open up the posts of a category for the public.
if(!(WA_Auth_RulePasses('Logged in to tblUserLoginsExt')) && !is_front_page()) { $_SESSION['redirUrl'] = urlencode($_SERVER['REQUEST_URI']); echo $_SESSION['redirUrl']; header('Location: http://www.melett.'. $ext .'/turbohub?redirect=true'); } if(is_category('latest-news')) header('Location: http://www.melett.'. $ext .'/turbohub-news.php');That’s the PHP to determine if there is a redirect or not.
-
Okay, I was able to figure it out.
Rather simple, I wrapped the first if statement within another: if (!in_category(‘latest-news’)).
So now, if you are not logged in, you cannot view any page other than the home page and the latest news posts. If you try to go to the latest news page (with all the posts), you are redirect out of the site.
- The topic ‘Redirect – if not logged in, on front page, or in category?’ is closed to new replies.