Content Restriction / Visibility Shortcode

Hide and Show Content with the Content Shortcode #

The following shortcode can be used to restrict content, so that it can be seen only by groups/b2b/b2c/users

[b2bking_content show_to=b2b]Your content here...[/b2bking_content]

The parameter show_to is mandatory. This parameter can contain multiple items, comma-separated. The parameter supports 5 elements:

  • b2b
  • b2c
  • loggedout
  • b2bking group IDs (e.g. 71, 343, 5884. Each business group has its own ID, which is visible in the link of the group's page when you click edit group)
  • usernames e.g: admin, user, mike.johnson, mazda.213

More examples:

[b2bking_content show_to=b2c,loggedout,admin]Your content here...[/b2bking_content]

In this example: b2c users, logged out users, and the user "admin" will see content

[b2bking_content show_to=123,b2c,loggedout,admin]Your content here...[/b2bking_content]

In this example: b2b users in the group with ID 123, b2c users, logged out users and the user admin will see the content.

[b2bking_content show_to=123,14,88]Your content here...[/b2bking_content]

In this example: b2b users in groups 123,14 and 88 will see the content.

How to apply CSS for B2B / B2C users only #

The shortcode above will not be applicable to all situations. An often encountered scenario would be a need to apply CSS for only particular users.

B2BKing adds classes to the body tag:

(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)

That way for example you can hide some menu items for logged out users by simply using:

.b2bking_logged_out #menu_item{

Powered by BetterDocs