WP Plugin to restrict access to the Shop section without login

Donbuffy

Power Member
Joined
Jul 23, 2012
Messages
719
Reaction score
188
Been doing some research on my own, and it hit me... i have to ask here
Working on an e-commerce website using woocommerce and i dont want visitors to be able to open the shop section or see any e-commerce related segment of the site without signup or login

who knows any plugin that do such?
 
Why would you do that. Most of your customers would probably leave and what do you gain with them creating a account.
Only email which they give you at checkout

Also just have a pop that says get ____ for free. And then spot for their email
 
You can use literally any membership plugin for that. (All free membership plugins will have that functionality as well)
 
If you have your catalog price public and just want to have authenticated inside your shop, keep in mind to don't give unauthorized for crawlers.
The plugins may block users and crawlers (don't know if you have that role in some of them). If you block them, your shop won't be index :(

If you don't want a plugin to override your site something like this should do it

add_action( 'init', 'protect_store_non_logged_users' );

function protect_store_non_logged_users() {

$ids = array(1,2,3); // custom woocommerce pages
if ( (!is_user_logged_in() && is_shop()) ||
!is_user_logged_in() && in_array(get_the_ID(), $ids) ) { // custom code need to check for crawlers but there're libs of course
wp_redirect(wp_login_url());
exit;
}
}
 
Why would you do that. Most of your customers would probably leave and what do you gain with them creating a account.
Only email which they give you at checkout

Also just have a pop that says get ____ for free. And then spot for their email
its the request of the site owner am designing for... besides i could get them to signup before checout by default using woocommerce plugin, but i'l rather prefer when they go to the shop section they see a signup first button
 
If you have your catalog price public and just want to have authenticated inside your shop, keep in mind to don't give unauthorized for crawlers.
The plugins may block users and crawlers (don't know if you have that role in some of them). If you block them, your shop won't be index :(

If you don't want a plugin to override your site something like this should do it

add_action( 'init', 'protect_store_non_logged_users' );

function protect_store_non_logged_users() {

$ids = array(1,2,3); // custom woocommerce pages
if ( (!is_user_logged_in() && is_shop()) ||
!is_user_logged_in() && in_array(get_the_ID(), $ids) ) { // custom code need to check for crawlers but there're libs of course
wp_redirect(wp_login_url());
exit;
}
}
you have a point mate, i could add this to the functions.php file right?
 
You can use literally any membership plugin for that. (All free membership plugins will have that functionality as well)
trying at a couple of membership plugins now, would update later :)
 
Yes you need to add it to theme functions.php or a custom plugin. I would rather try to do it with code instead of having dozens of PHP files being added to the stack for just a minimal functionality.

But i have WP in low cost vps, if you have money go with plugins and save time :)
 
Back
Top