WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following function works perfectly when logged-in visitors go to http://sitename.com, taking them to the site homepage. When logged-in visitors go to http://www.sitename.com, however, they're incorrectly redirected to http://sitename.com/splashpage. Does anyone know what's causing this?

I have tried switching my site settings to use http://www.sitename.com as the WordPress and Site Address URLs, but that simply reverses the issue so it incorrectly redirects when a logged-in user goes to http://sitename.com.

add_action ('template_redirect','mkm_restrict_access',1);
function mkm_restrict_access() {
    $url = site_url('/splashpage/');
    if (is_page('splashpage') || is_page('login')) {
        //do nothing
    } elseif (!is_user_logged_in()) {
        wp_redirect( $url ); 

Thank you for your help!

share|improve this question
Is there perhaps a better action to use to call this redirect? Something that fires after the page redirects from example.com to example.com ? – Michelle Aug 4 '11 at 19:39
up vote 0 down vote accepted

Figured it out, though this is the lamest solution ever: I hooked into wp_footer instead of template_redirect. If anyone has a better solution or place to hook in I'd love to hear about it - thanks!

EDIT: That wasn't the fix I thought it was. Turned out I was writing the function poorly, and did need to be using template_redirect. See Cannot get redirect working

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.