Last active
October 2, 2016 17:34
-
-
Save neilgee/adc37c2e50dcd5371c79 to your computer and use it in GitHub Desktop.
Hide WooCommerce Pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Dont copy the above opening php tag | |
//Hide WooCommerce from non-logged in users | |
function woocommerce_hide_non_registered() { | |
if( ( is_shop() || is_product() || is_product_category() ) && ! is_user_logged_in() ) { | |
wp_redirect( site_url( '/' ) ); | |
exit(); | |
} | |
} | |
add_action( 'template_redirect','woocommerce_hide_non_registered' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment