1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WP Plugin to restrict access to the Shop section without login

Discussion in 'Membership Sites' started by Donbuffy, Jul 20, 2016.

  1. Donbuffy

    Donbuffy Jr. VIP Jr. VIP

    Joined:
    Jul 23, 2012
    Messages:
    374
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Self Employed
    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?
     
  2. Lunaaa

    Lunaaa Jr. VIP Jr. VIP

    Joined:
    Jan 18, 2016
    Messages:
    2,415
    Likes Received:
    1,246
    Gender:
    Male
    Location:
    Canada
    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
     
  3. KraftyKyle

    KraftyKyle Jr. Executive VIP Jr. VIP Premium Member

    Joined:
    Aug 13, 2008
    Messages:
    2,033
    Likes Received:
    4,801
    Gender:
    Male
    Location:
    Unknown
    You can use literally any membership plugin for that. (All free membership plugins will have that functionality as well)
     
  4. Guilherme Cardoso

    Guilherme Cardoso Newbie

    Joined:
    Sep 29, 2014
    Messages:
    15
    Likes Received:
    3
    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;
    }
    }
     
    • Thanks Thanks x 1
  5. Donbuffy

    Donbuffy Jr. VIP Jr. VIP

    Joined:
    Jul 23, 2012
    Messages:
    374
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Self Employed
    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
     
  6. Donbuffy

    Donbuffy Jr. VIP Jr. VIP

    Joined:
    Jul 23, 2012
    Messages:
    374
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Self Employed
    you have a point mate, i could add this to the functions.php file right?
     
  7. Donbuffy

    Donbuffy Jr. VIP Jr. VIP

    Joined:
    Jul 23, 2012
    Messages:
    374
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Self Employed
    trying at a couple of membership plugins now, would update later :)
     
  8. Zemar

    Zemar Newbie

    Joined:
    Oct 13, 2015
    Messages:
    21
    Likes Received:
    1
    You can search many plugins :)
     
  9. Guilherme Cardoso

    Guilherme Cardoso Newbie

    Joined:
    Sep 29, 2014
    Messages:
    15
    Likes Received:
    3
    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 :)
     
    • Thanks Thanks x 1