Woocommerce Logged in Only

Restrict Woocommerce pages to logged in usesrs only:

/****************** Logged in Only *************************/
function woo_loggedin_redirect() {
 if (
 ! is_user_logged_in()
 && (is_woocommerce() || is_cart() || is_checkout())
 ) {
 // feel free to customize the following line to suit your needs
 wp_redirect(home_url());
 exit;
 }
}
add_action('woo-loggedin_redirect', 'woo_loggedin_redirect');

 

Similar Posts