• Plans & Pricing
  • Log in
  • Get started
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress 
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Get started
  • Sign up
  • Log in
About
  • Plans & Pricing
Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress  
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Jetpack App
  • Learn more
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Search
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Forums / Redirect – if not logged in, on front page, or in category?

Redirect – if not logged in, on front page, or in category?

  • Unknown's avatar
    quin452 · Member · Oct 21, 2015 at 2:38 pm
    • Copy link Copy link
    • Add topic to favorites Add topic to favorites

    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.

  • Unknown's avatar
    quin452 · Member · Oct 21, 2015 at 2:52 pm
    • Copy link Copy link

    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.

Tags

  • external login system
  • not logged in
  • php
  • posts
  • protected content
  • redirect
  • WordPress

About this topic

  • In: Support
  • 1 participant
  • 1 reply
  • Last activity 10 years
  • Latest reply from quin452

Couldn't find what you needed?

Contact us

Contact us

Get answers from our AI assistant, with access to 24/7 expert human support on paid plans.

Browse our guides

Browse our guides

Find step-by-step solutions to common questions in our comprehensive guides.

WordPress.com

Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Professional Email
  • Website Design Services
  • WordPress Studio
  • Enterprise WordPress
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • WordPress.com Blog
  • Business Name Generator
  • Logo Maker
  • WordPress.com Reader
  • Accessibility
  • Remove Subscriptions
Help
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
  • Developer Resources
Company
  • About
  • Press
  • Terms of Service
  • Privacy Policy
  • Do Not Sell or Share My Personal Information
  • Privacy Notice for California Users
DeutschEspañolFrançaisBahasa IndonesiaItalianoNederlandsPortuguês do BrasilSvenskaTürkçeРусскийالعربيةעִבְרִית日本語한국어简体中文繁體中文English

Mobile Apps

  • Download on the App Store
  • Get it on Google Play

Social Media

  • WordPress.com on Facebook
  • WordPress.com on X (Twitter)
  • WordPress.com on Instagram
  • WordPress.com on YouTube

Automattic

Automattic
Work With Us
    • WordPress.com Forums
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • Manage subscriptions