function redirect_woocommerce_pages_itc() { $current_url = $_SERVER['REQUEST_URI']; if ( strpos( $current_url, '/shop' ) !== false ) { if ( ! is_user_logged_in() ) { wp_redirect( 'https://' ); exit; } } } add_action( 'template_redirect', 'redirect_woocommerce_pages_itc', 999 );