WooCommerce

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() );
        exit;
    }
}

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.
Previous Post
Featured Site: Safe Healthcare For Every Woman
Next Post
Client Testimonial: Brooms Over Broome

Related Articles

Menu
Google Rating
5.0
Based on 56 reviews
×
Get a Quote