Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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

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 to ? – Michelle Aug 4 '11 at 19:39

1 Answer 1

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.