Hide WooCommerce for Unregistered Users in WordPress

You can hide the core pages of WooCommerce from unregistered users using a simple WordPress redirect function called template_redirect.

This may come in handy if the woocommerce component is still in development or has a delayed release or is for WordPress registered users only.

Add to your functions.php file

The code will essentially redirect any user that is not logged in to a redirect page – this is declared in the wp_redirect() component which above is set to the home page, to set it to another page just change the value for the site_url()


  1. Michael on December 4, 2018 at 5:14 am

    Awesome! Works perfect

  2. carlos on March 10, 2018 at 12:56 pm

    It’s work with all the subpages of woocommerce but with the main shop, NOT!!!! why???

  3. Dave on January 27, 2017 at 9:58 am


  4. nic on November 10, 2016 at 1:08 pm

    Please can you explain why it is not working on a child theme? Thanks

    • Neil Gowran on November 10, 2016 at 7:56 pm

      The code snippet works equally in child themes

  5. Jos on September 21, 2016 at 7:52 am

    Simple and to the point. Thanks,

  6. simone on August 6, 2015 at 3:40 pm

    Thank you such a help!!!

Leave all Comment