Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@neilgee
Last active October 2, 2016 17:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save neilgee/adc37c2e50dcd5371c79 to your computer and use it in GitHub Desktop.
Save neilgee/adc37c2e50dcd5371c79 to your computer and use it in GitHub Desktop.
Hide WooCommerce Pages
<?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