-
Ok, I’ve checked everything for a couple of hours and I can’t restrict access to my woocommerce Shop Page…
I’ve changed the option of my shop page in the poste meta, I’ve deactivated all my plugins except woocommerce & userpro, no results, still seing the products if i’m not logged in.Anyone having the same issue?
Hi mcmedia79,
Please read the rules before posting support threads. Your topics may be removed If you do not read this first. We appreciate your cooperation to make this community better.
In particular the Howto on step 1 to verify your purchase.
Should save you some time in getting support.
Sorry about that, my purchase key has been added to my account.
Back to my topic,
I’ve inserted this code in woocommerce theme file (archive_products.php) and it worked :
if( !is_user_logged_in() ) {
wp_redirect( home_url(‘/login’) );
}
else{
//rest of the code
}The only problem is that it’s not redirecting the user to the page they where trying to access before login in.
If you have a better way please inform me.
Sorry, I was going to provide the same solution for you.
But maybe Ahmed will find a better way. If it’s the case I would be definitely interested too.
Can’t you restrict the page from page settings/editor? Or is it a category/archive?
I introduced new restrict option that works by just checking “a checkbox” in each post/page/product/etc
Nope, the page /shop/ still loads products even if I check the option…
The problem is that any plugins which can limit access by user level do not work on WooCommerce “Core” pages (ie: the shop page). So, what you did (editing the archive-product.php file (found in the WooCommerce root dir) and add some custom php code to the very top was the right thing to do.
PS: Just a tip: Create the WooCommerce folder under the base folder of your active theme and copy archive-product.php from woocommerce/templates there.
You must be logged in to reply to this topic.