Redirection from a specific page for users logged in but not with membership

Question

I am trying to redirect logged in user but not with a membership, from a specific page to product page. But it is showing error if I land on that page. Let’s say join is the page with id 1867. Here is my code:

function redirect_member_to_product(){
    if (is_page(1867)){
        if (is_user_logged_in() && !wc_memberships_is_user_active_member('channel-mcgilchrist')){
            template_redirect('/product/channel-mcgilchrist');
            exit;
        }
    }
}
add_action('template_redirect', 'redirect_member_to_product');

What I am doing wrong here?

0
, , , Nayan Chowdhury 1 year 2020-07-13T01:10:22-05:00 0 Answers 59 views 0

Leave an answer

Browse
Browse