Woocommerce - Open the product page only if the user is logged in

0

Good afternoon, I need a method that understands whether the user is logged in or not to access the product details page.

I'm using a Woocommerce (Storefront) to manage a product site, and would like the user to be able to see the products on Home, but clicking the button to enter and viewing the product details will be done a registration / login check and you can only see the product details if you are logged in, otherwise you will be redirected to the registration / login page.

Thank you in advance.

    
asked by anonymous 05.11.2015 / 20:41

1 answer

1

The syntax used to show something only if the user is logged in is:

<?php if ( is_user_logged_in() ) { ... } ?>
  

Reference: Function Reference / is logged in

You also have these two plugins here, which do exactly that:

Page Restrict
WordPress Access Control

    
05.11.2015 / 23:48