1. Home
  2. Knowledge Base
  3. WooCommerce Wholesale Prices Premium
  4. Product Visibility
  5. How to show or hide content from wholesale customers with shortcodes

How to show or hide content from wholesale customers with shortcodes

If you want part of a product page, post, or page to appear only for your wholesale customers, or to hide certain content from them entirely, WooCommerce Wholesale Prices Premium includes two shortcodes built for that: [wholesale_content] and [hide_from_wholesale].

This article covers how each shortcode works, how to target specific wholesale roles instead of any wholesale customer, and how these shortcodes behave for guests and regular retail customers.

Requirements

  • WooCommerce installed and active.
  • WooCommerce Wholesale Prices Premium installed and activated. These shortcodes are not available in the free WooCommerce Wholesale Prices plugin.
  • At least one wholesale role created and assigned to the customers you want to target. Configure this under Wholesale → Roles.

Show content only to wholesale customers

Wrap any content in the [wholesale_content] shortcode to make it visible only to customers who are logged in with a wholesale role. Everyone else, including guests and regular retail customers, does not see the content at all.

[wholesale_content]Here is my content that is only visible to any wholesale user[/wholesale_content]

Content placed inside [wholesale_content] is still processed for shortcodes, so you can nest other shortcodes inside it.

Hide content from wholesale customers

Use the [hide_from_wholesale] shortcode for the opposite result. Content wrapped in it is visible to everyone except customers who are logged in with a wholesale role.

[hide_from_wholesale]Content that any wholesale user should not see[/hide_from_wholesale]

Target specific wholesale roles

By default, both shortcodes apply to any wholesale role. Add a role attribute to target one or more specific roles instead.

  1. Go to Wholesale → Roles.
  2. Note the value shown in the Key column for each role you want to target. This is the value the shortcode’s role attribute expects, not the role’s display name.
Wholesale Roles table showing the Key column values for each wholesale role
Wholesale → Roles: the Key column holds the value to use in the shortcode’s role attribute

Use the role key in the [wholesale_content] shortcode to show content only to the listed roles:

[wholesale_content role="wholesale_second_level,wholesale_third_level"]Here is my content that is only visible to the specified roles[/wholesale_content]

Separate multiple role keys with commas. Spaces around each key are trimmed automatically, so wholesale_second_level, wholesale_third_level and wholesale_second_level,wholesale_third_level both work. A customer only needs one of the listed roles to match, not all of them.

The same role attribute works on [hide_from_wholesale] to hide content from specific roles only:

[hide_from_wholesale role="wholesale_second_level"]Content that is hidden from the second level wholesale role[/hide_from_wholesale]

Troubleshooting

Why isn’t wholesale-only content showing for a customer who is logged in?

Confirm the customer’s account has a wholesale role assigned under Users. If the shortcode uses a role attribute, also confirm it matches the exact value shown in the Key column under Wholesale → Roles. Role keys are case-sensitive.

Does this restriction apply to administrator or shop manager accounts?

Not unless that account is also assigned a wholesale role. An administrator or shop manager account without a wholesale role is treated the same as any other non-wholesale visitor: [wholesale_content] stays hidden and [hide_from_wholesale] content is shown.

Why does the shortcode show up as plain text instead of showing or hiding content?

Shortcodes only render where WordPress actually processes them, such as post content, page content, and product descriptions. Some widget areas and page builder text fields do not run shortcodes by default. Test the shortcode in a standard page or product description to confirm it renders correctly.

Frequently asked questions

Does this feature require WooCommerce Wholesale Prices Premium?

Yes. Both shortcodes are part of WooCommerce Wholesale Prices Premium and are not included in the free WooCommerce Wholesale Prices plugin.

What happens for a guest visitor who isn’t logged in?

A guest has no wholesale role, so [wholesale_content] content stays hidden and [hide_from_wholesale] content is shown, the same as for a logged-in retail customer.

Can I nest other shortcodes inside [wholesale_content] or [hide_from_wholesale]?

Yes. Content inside both shortcodes is processed for shortcodes, so any shortcode nested inside renders normally.

What happens if a customer has more than one wholesale role assigned?

If the shortcode does not use a role attribute, having any wholesale role is enough. If the role attribute lists specific roles, the customer needs at least one of their assigned roles to be in that list.

It’s also generally not recommended for the wholesale customer to have more than 1 wholesale role, as they can conflict with one another and cause issues.

Do I use the role’s name or its key in the role attribute?

The role key, not the display name. Find it in the Key column under Wholesale → Roles.

Can I use these shortcodes in a product description, a post, or a widget?

Yes. They work anywhere WordPress processes shortcodes, including product short and long descriptions, pages, posts, and shortcode-enabled widgets.

Can I use both shortcodes together on the same page?

Yes. Each shortcode instance is evaluated independently, so you can combine multiple [wholesale_content] and [hide_from_wholesale] blocks anywhere on the same page.

Does whitespace in the role attribute matter?

No. Extra spaces around each role key are trimmed automatically before the roles are compared.

Help & support

We have a dedicated support team for Wholesale Suite who knows our products, WooCommerce, and the industry very well. You’re welcome to make use of their expertise at any time, worldwide.

If you are an existing customer please go to the support ticket request form and send us a message.

If you are a free plugin user, please send us a support request on the forum. We actively monitor the WordPress.org support forums for the free plugin and help our users there as best as we can.

Was this article helpful?

Related Articles

Complete Your Purchase