In WooCommerce I am redirecting non logged users to My Account page when they visit any WooCommerce page. But after user login (in My Account page) when I try to visit that same woocommerce page it’s redirect me to My Account page.
But when I visit any other WooCommerce pages its working perfect.

I am using this code for this purpose:

    if ( !is_user_logged_in() ) {
        if(is_woocommerce() || is_shop() || is_cart() || is_checkout())  {

            wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id')) );

I think the problem is that it stores something in cache or another redirection issue, so when user visit same url it’s redirected to My Account when is logged in.

How can I solve this problem.


Read more here: Redirect WooCommerce pages to My Account page if not logged in (Issue)


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: