• Resolved karinaardachtig

    (@karinaardachtig)


    Hi Support,

    We have the members (bought) plugin installed, and some products have the restriction of showing only when a user with specific userrole logs in. However, everyone sees the restricted product, the plugin is not working.

    I’ve updated every plugin and wordpress, i’ve disabled plugins, but nothing works.

    Any suggestions?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Omar ElHawary

    (@omarelhawary)

    Hi @karinaardachtig,

    Thanks for reaching out Members Support Team!

    We don’t have such an option to remove products in shop page. That will require custom developement.

    Regards,

    Thread Starter karinaardachtig

    (@karinaardachtig)

    Hi @omarelhawary,

    It is not a matter of deleting/removing.

    We want different userroles that can view specific products, that is why we bought this plugin.
    With every woo-commerce product we can select which role sees which products, but when we apply this, everybody (also customer outside the specific userrole) can see the product.

    Hope to hear from you.

    Kind regards.

    Plugin Support Omar ElHawary

    (@omarelhawary)

    Hi @karinaardachtig,

    May I ask which plugin you’ve bought as Members plugin is free?

    Regards,

    Thread Starter karinaardachtig

    (@karinaardachtig)

    Hi Omar,

    When i check my installed plugins i see; Members – Membership & User Role Editor Plugin…
    When i click to ‘check details’ en click on ‘go to homepage’ i get: https://members-plugin.com/
    Then i click the support link and end up here.
    It is not a free app: https://memberpress.com/plans/pricing/

    The problem still here, i would like to hide/show products for certain user roles. The plugin states it can do that, even gives the functionality, but it seems not be working…

    kind regards.


    Thread Starter karinaardachtig

    (@karinaardachtig)

    Hi,

    Any thoughts on the subject?

    kind regards.

    Plugin Support Omar ElHawary

    (@omarelhawary)

    Hi @karinaardachtig,

    I checked with dev team and kindly find the reply below:

    The Members is a free plugin. It doesn’t fully protect a WooCommerce product on the frontend. It currently only protects post content. WooCommerce templates show post content (which is protected), but it shows a lot more, such as price, short description, etc., which is usually post meta.
    That’s being said, here’s a snippet that will redirect logged-in users when they don’t have a required role and the product has sneakers or backpacks categories:

    add_filter( 'woocommerce_product_is_visible', 'members_maybe_remove_product_from_query', 95, 2 );
    /**
    * Removes a product from the query depending on if the user has the correct permission.
    *
    * @param boolean $is_visible Whether the product is visible
    * @param int $product_id Product ID
    *
    * @return boolean
    */
    function members_maybe_remove_product_from_query( $is_visible, $product_id ) {
    return members_can_current_user_view_post( $product_id );
    }
    add_action( 'template_redirect', 'members_woocommerce_product_redirect' );
    function members_woocommerce_product_redirect() {
    if ( class_exists( 'WooCommerce' ) && is_singular( 'product' ) ) {
    $user = wp_get_current_user();
    $post_id = get_the_ID();
    if( ! empty($user) && in_array( 'author', (array) $user->roles ) && has_term( array( 'sneakers', 'backpacks' ), 'product_cat', $post_id ) ) {
    wp_redirect( apply_filters( 'members_woocommerce_product_redirect', get_permalink( wc_get_page_id( 'shop' ) ) ) );
    exit;
    }
    }
    }

    If you want to use it for particular product, you’ll need to modify?has_term?part in the condition above.

    Regards,

    Thread Starter karinaardachtig

    (@karinaardachtig)

    Hi,

    My appologies for getting two plugins mixed up.
    However your solutions does not fix our problem. The plugin seemed to be what we needed, but had to uninstall. Thank you however for your support/help.

    kind regards.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.