Here is my code:

add_action('template_redirect', 'ep_tags_redirect_lockout');
function ep_tags_redirect_lockout() {
    if ( is_user_logged_in() ) {
    //echo 'XXXXXX';
    if (
        is_page( array(
        ) )
    ) {
        wp_redirect( site_url( '/' ) );

I can tell it gets to the echo statement (when not remarked) but never produces a positive condition with the is_page() function. I've tried post IDs, slugs, and page names.

Since this is running with the hook 'template_redirect' it should be safe to assume that the page ID is loaded by this time.

  • Are you sure your not logged in? :) – RiddleMeThis Sep 10 '18 at 19:29
  • I don't see anything wrong with the code, tested on my install and it works. – RiddleMeThis Sep 10 '18 at 19:35
  • this code will never get to the redirect if you're logged in... is that what you wanted. – rudtek Sep 10 '18 at 19:49
  • It is supposed to redirect if NOT logged in. That's where I'm having trouble. I'm sure I'm not logged in, and to prove it to myself (among other things) if I uncomment the echo statement, I do see THAT. – De Coder Sep 10 '18 at 20:28
  • Are new-tag and edit-profile actually pages? If new-tag is a tag, then you need to use is_tag(). – Jacob Peattie Sep 11 '18 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.