Hide WooCommerce Products & Pages For Logged Out Users

The following code will hide WooCommerce products and pages for any logged out users, as well as redirect to the homepage.

Happy developing!

// redirecting woocommerce pages to homepage for logged out users
add_action('template_redirect', 'fs_wc_redirect');
function fs_wc_redirect() {
    if ( ! is_user_logged_in() && (is_woocommerce() || is_cart() || is_checkout()) ) {
        wp_redirect( home_url() );

Need help?

Tell us about your project!

  • Date Format: MM slash DD slash YYYY
  • This field is for validation purposes and should be left unchanged.

Related articles

Google Rating
Based on 62 reviews