Content Restriction Shortcode, Content Visibility, Apply CSS for B2B / B2C / Specific Groups Only.

Content Restriction Shortcode #

B2BKing's content shortcode can be used to show different content to different user categories, groups or individual customers, restricting who can view the specific content you place inside the shortcode.

Here are a few examples of what can be done with this shortcode:

  • On the same page, show different content to B2B and B2C users
  • On a product description page, show some extra wholesale information that only logged in B2B users can see
  • On the Terms & Conditions page, show different terms and conditions to B2B users.
  • Show different content to logged in and logged out users
  • Show content based on username, so that only specific users can see it

Note: The content restriction shortcode can be used anywhere: pages, product descriptions, as well as any custom elements or widgets that support shortcodes.

Usage Example

[b2bking_content show_to=b2b]Only B2B users can view this content...[/b2bking_content]

The parameter show_to is mandatory and controls who can view the specific content within the shortcode. This parameter can contain multiple items, comma-separated. The parameter supports 6 options:

  • b2b
  • b2c (only refers to logged in b2c users)
  • loggedout
  • b2bking group IDs (e.g. 12, 345, 5884. Each group has its own ID, which is visible in the link of the group's page when you edit the group)
  • usernames e.g: admin, user, mike.johnson, mazda.213
  • purchased a specific product, e.g. bought1234, bought4567 (New!)

More examples:

[b2bking_content show_to=b2c,loggedout,admin]Only B2C users, logged out users, and the user "admin" will see this content.[/b2bking_content]

[b2bking_content show_to=123,b2c,loggedout,admin]B2B users in the group with ID 123, B2C users, logged out users and the user admin will see this content.[/b2bking_content]

[b2bking_content show_to=123,14,88]Only B2B users in groups 1234, 14 and 88 will see this content[/b2bking_content]

[b2bking_content show_to=bought1234]Only users who purchased the product with ID 1234 can see this content. This can be used to lock specific content under a paywall.[/b2bking_content]

Page Example #

Let's see what this look like when working with an actual page.

Different Content for B2B and B2C / Logged Out Users

The above example shows a page where we have different content for B2B and B2C or logged out users.

When viewing the page as a logged in B2B user, the page looks like this:

Example: Page as seen by a B2B user

When viewing the page as a logged out user, the page looks like this:

Example: Page as seen by a logged out user

How to apply CSS for B2B / B2C users only #

While the content restriction shortcode deals with the actual content inside the page, another common situation is needing to apply CSS (and specific design changes) for particular users or groups only. This can be achieved through group-specific CSS.

B2BKing adds classes to the body tag, that can be used to target specific groups only:

4062340251.png
(here you can see b2bking_b2c_user)

The classes you can use are:

  • b2bking_b2b_user
  • b2bking_b2c_user
  • b2bking_logged_out
  • b2bking_b2b_group_123 (replace 123 with your group id)
  • b2bking_subaccount

Example

Hide a menu items for logged out users only by adding this CSS:

.b2bking_logged_out #menu_item{
    display:none;
}

Example 2

Show a different background color for B2B and B2C users

.b2bking_b2b_user body{
    background:blue;
}
.b2bking_b2c_user body{
    background:green;
}

Powered by BetterDocs