template_redirect action only firing if logged in

Question
add_action('template_redirect', 'add_header_redirect', 0, 0);
function add_header_redirect(){
    if( is_page(array(8, 'testimonials', 'Testimonials')) ){
        $default_testimonial = get_permalink( 19 );
        header("Location: $default_testimonial");
    }
}

this code is in my functions.php file and ONLY works when I am logged into WP. I want all users who go to /testimonials to be redirected. what’s going on?

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/template_redirect-action-only-firing-if-logged-in/">

template_redirect action only firing if logged in</a>
0
, , zack 8 years 0 Answers 48 views 0

Leave an answer