Why Your WooCommerce Products Are Still Visible After Using Members Plugin
Content
Many WordPress users rely on the Members – Membership & User Role Editor Plugin to manage access to their content. A very common question we see is: "I've set content permissions on my WooCommerce product, but it's still visible to everyone! What's wrong?"
The Core Issue: What Members Actually Protects
Based on extensive community discussion, the most important thing to understand is the plugin's fundamental limitation with WooCommerce. The Content Permissions feature in the Members plugin is designed to protect the main content of a post or page—specifically, the text you write in the WordPress editor.
WooCommerce products, however, are built differently. While the plugin will successfully hide the product's long description (the main content), a WooCommerce template displays much more:
- Product Price
- Short Description (Excerpt)
- "Add to Cart" Button
- Product Images & Gallery
- Related Products
- Meta Data (SKU, categories, tags)
These elements are not part of the main post content; they are generated by WooCommerce's template system using post meta and other functions. Therefore, the Members plugin's content protection does not hide them, and the product remains largely visible and purchasable.
Common Solutions and Workarounds
1. Use a Code Snippet to Hide the Entire Product
The most effective solution provided in the community is to use a custom code snippet. This code hooks into WooCommerce's visibility check and can completely remove a product from shop archives, search results, and single product views if a user lacks the required role.
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 ) {
// Replace 'subscriber' with the slug of your required role.
if ( ! members_user_has_role( get_current_user_id(), 'subscriber' ) ) {
$is_visible = false;
}
return $is_visible;
}
Important: This is a basic example. You would need to add logic to check for specific products or categories. Adding this code requires familiarity with editing your theme's `functions.php` file or using a code snippets plugin.
2. For Hiding Specific Elements (Like Price)
If your goal is not to hide the entire product but just specific elements like the price for certain users, you can use conditional checks in your theme's template files.
// Example: Hide price for non-logged-in users
if ( is_user_logged_in() ) {
echo wp_kses_post( $product->get_price_html() );
}
Alternatively, you can use the Members plugin's shortcodes within the product description to wrap specific content:
[members_access role="your-custom-role"]This special offer is only for you![/members_access]
[members_not_logged_in]Please log in to see your discounted price.[/members_not_logged_in]
Key Takeaways
- Not a Bug: This behavior is not a bug in the Members plugin but a result of how it interacts with WooCommerce's complex template structure.
- Content vs. Product: The plugin protects post content, not the entire WooCommerce product page.
- Custom Code is Required: For full product restriction, custom code is necessary. The Members plugin team has acknowledged this in their support responses and frequently provides code snippets as a starting point.
- Consider a Dedicated Plugin: If writing code is not feasible, you may want to investigate plugins built specifically for WooCommerce product restriction based on user role.
Understanding this distinction between content and product protection is the first step to finding the right solution for your store. While it requires some technical effort, achieving full product restriction is possible with the right approach.
Related Support Threads Support
-
Hide Product for different roleshttps://wordpress.org/support/topic/hide-product-for-different-roles/
-
Hide Retail Price for Logged-in Usershttps://wordpress.org/support/topic/hide-retail-price-for-logged-in-users/
-
WooCommerce Productshttps://wordpress.org/support/topic/woocommerce-products-44/
-
Members plugin not restricting access to Woo productshttps://wordpress.org/support/topic/members-plugin-not-restricting-access-to-woo-products/
-
Request for Price Visibility Control by User Rolehttps://wordpress.org/support/topic/request-for-price-visibility-control-by-user-role/
-
Restrict WooCommerce Productshttps://wordpress.org/support/topic/restrict-woocommerce-products-3/
-
duplicate accesshttps://wordpress.org/support/topic/duplicate-access/
-
product is still visiblehttps://wordpress.org/support/topic/product-is-still-visible/
-
Product viewablehttps://wordpress.org/support/topic/product-viewable/
-
Hello! The product is not hiddenhttps://wordpress.org/support/topic/hello-the-product-is-not-hidden/
-
Related products Problemhttps://wordpress.org/support/topic/related-products-problem-2/
-
private products viewed by retailershttps://wordpress.org/support/topic/private-products-viewed-by-retailers/
-
Private products don’t appear in taxonomieshttps://wordpress.org/support/topic/private-products-dont-appear-in-taxonomies/
-
members and woocommercehttps://wordpress.org/support/topic/members-and-woocommerce/
-
Role per price do not Workhttps://wordpress.org/support/topic/role-per-price-do-not-work/
-
product page doesn’t appearhttps://wordpress.org/support/topic/product-page-doesnt-appear/
-
Grant Duplicate Product, Deny Manage WooCommercehttps://wordpress.org/support/topic/grant-duplicate-product-deny-manage-woocommerce/
-
Can you add ‘read_others_products’ capabilityhttps://wordpress.org/support/topic/can-you-add-read_others_products-capability/
-
Enable product reviews user rolehttps://wordpress.org/support/topic/enable-product-reviews-user-role/
-
Display Woo Product to certain User Roleshttps://wordpress.org/support/topic/display-woo-product-to-certain-user-roles/
-
Woo commerce duplicate productshttps://wordpress.org/support/topic/woo-commerce-duplicate-products/
-
Show only productshttps://wordpress.org/support/topic/show-only-products-2/
-
Content permission does not workhttps://wordpress.org/support/topic/content-permission-does-not-work/
-
Hide price for custom rolehttps://wordpress.org/support/topic/hide-price-for-custom-role/
-
Woocommerce product show only to specific rolehttps://wordpress.org/support/topic/woocommerce-product-show-only-to-specific-role/
-
Access for Product page does’nt workhttps://wordpress.org/support/topic/access-for-product-page-doesnt-work/
-
How to block access to a Woocommerce product?https://wordpress.org/support/topic/how-to-block-access-to-a-woocommerce-product/
-
Search Resultshttps://wordpress.org/support/topic/search-results-135/