In WordPress website with Woocommerce looking for solutions to restrict you Woocommerce Shop, Product Archive, Product Detail page, Cart, Checkout etc pages only accessible for Logged In user and if user not logged in and try to access Woo-Commerce pages than redirect them to either Home page or any specific page you can easily do it by use of template_redirect action in WordPress.
See Below solution for How can I redirect not logged in users to login or other page if they try to access Woo-Commerce Pages with out Sign-Up / Login ?
Want to make like Woo Commerce pages accessible only for already Logged In user ? add following code in your active theme functions.php file
# function wdo_user_redirect() { if (! is_user_logged_in() && (is_woocommerce() || is_cart() || is_checkout())) { wp_redirect(home_url()); // if user not logged in redirect them to Home page. if you want to redirect on any other page set Url your destination page. exit; } } add_action('template_redirect', 'wdo_user_redirect');
You must be logged in to post a comment.