WordPress.org

Ready to get started?Download WordPress

Forums

Need to hide WooCommerce 'shop' page to non members (5 posts)

  1. casbahdesignart
    Member
    Posted 1 year ago #

    Hi there.

    I'm running on online shop using WooCommerce and have hidden certain pages from non registered customer using the plugin 'member access' ('http://wordpress.org/extend/plugins/member-access/) which allows me to manually configure what user roles are allowed to see what pages. So I've set the WooCommerce shop base page to 'Shop', and using the plugin I've made it only accessible to registered customer using an assigned user role after registration.

    However, it isn't working, and I think it's to do with WooCommerce.

    I have no idea. Can somebody please help I'm super stuck on this issue for a client.

    Thank you in advance for any advice.

    Aaron

  2. gxb101
    Member
    Posted 1 year ago #

    This issues has plagued me for the last 2 days and I am happy to report I found a workaround. 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 must do is edit the archive-product.php file (found in the woocommerce root dir) and add some custom php code to the very top such as this:

    if( !is_user_logged_in() ) {
    	wp_redirect(some-page-on-your-site);
    }
    else{
    [the remaining original php code follows here...]

    What this will do is check to see if the user is logged in and redirect them to some other page is they aren't, else they will see the page as intended. The trick is to redirect them to some other page which makes them either login or register for site access.

    Problem solved.

  3. calzo
    Member
    Posted 1 year ago #

    I tried this and I got an error further down in the archive-product.php file.

    What is the exact string that I need to put in here: wp_redirect(some-page-on-your-site);

    I tried these: wp_redirect(http://website.com);
    wp_redirect("http://website.com)";
    wp_redirect('http://website.com');

    None of them worked.

  4. gxb101
    Member
    Posted 1 year ago #

    Hi, here is what I used at the very top:

    <?php
    if( !is_user_logged_in() ) {
    	wp_redirect(get_permalink(24));
    }
    else{

    [the rest of the original .php code....]

  5. Dan
    Member
    Posted 1 year ago #

    Just had the same issue while using the Groups plugin to the same end. Posted a comment on the author's site and he produced a workaround:

    http://www.itthinx.com/2013/02/12/how-to-hide-the-woocommerce-shop-page/

    To the OP, if you can replicate in Groups what you're doing in Member Access, this might be a solution for you.

Topic Closed

This topic has been closed to new replies.

About this Topic