Select Page

Recently we have developed a WooCommerce private shop for one of our client. If you have a private shop and want only registered user have access to the shop then you might want to keep the shop page private and force user to login. If you are looking for the solution then you have came to right place. Lets see the code snippet.

add_theme_support( 'woocommerce' );
function wpse_131562_redirect() {
if ( ! is_user_logged_in() && (is_woocommerce() || is_cart() || is_checkout()))
// feel free to customize the following line to suit your needs
add_action('template_redirect', 'wpse_131562_redirect');

Add the above code to tour themes functions.php file and you are done.