Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I can't get wp_redirect working correctly? I thought I'd figured this out (see wp_redirect not working when going to www version of site) but apparently not; no idea what changed between last week when it was working and now. I tried simplifying the function down but using the following I get an infinite-redirect error:

add_action ('after_setup_theme','mkm_restrict_access',10);
function mkm_restrict_access() {
    if (!is_user_logged_in() && !is_page('splashpage') && !is_page('login')) {
        wp_redirect('http://localhost.localdomain/clientname/wp/splashpage/'); 
        exit; 
    }
}

I've tried using wp_footer and almost everything up the chain in terms of calling the function but nothing seems to help. I am running Theme My Login and User Domain Whitelist, if that matters. I tried disabling them but it didn't help.

I suspect I'm doing something REALLY STUPID. :( Thanks for your help!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

none of those conditionals will work at after_theme_setup. Look at the Action Reference page in Codex for the order actions are executed in a request. Try hooking template_redirect instead.

share|improve this answer

Your Answer

 
discard

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.