When WordPress wins

Many years ago, I was stuck in a hot, windowless room on a hot, Friday afternoon, while members of Leeds Met Uni’s Communications and IT teams thrashed out what could and could not be achieved with the new web site (and the third version I helped them to deliver (although we don’t talk much about the second version)).

The argument was around the need to have internal-only content. No-one was keen on building a wholly separate site, and no-one wanted external visitors to have access to internal-only information.

Wanting to be anywhere but in that room, I suggested that the default home page, index.html, be replaced with a short script that checked the IP address of each visitor, as supplied by their browser as part of the way that the hypertext transfer protocol works (ooh, get me). If the IP range didn’t start with the batch that LMU had, they were an external visitor and would be served up one version of the home page; in-house visitors got the complete version.

My work done, I left others to finesse the details.

Spool forward 21-ish years, and I’m trying to do something similar with my WordPress-powered family tree web site. The basic code is this:

if (is_user_logged_in()) {
              wp_redirect('http://xxxxx/home1'; exit;
} else {
              wp_redirect('http://xxxxx/home2'; exit;
}

It doesn’t work. Of course it doesn’t! I just get a blank screen. That normally means a fail in the php syntax but there’s no error message. I’ve tried this as a special page template, as home.php and front-page.php, to no avail.

There is a way around this, by writing a composite home page and using a special template to hide text from not-logged-in users (or using a plugin, slightly easier) but that’s rather not the point.

Grr.

Post navigation

Previous post
Live from our text commentator
Next post
Why I envy joggers