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:
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.
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.
You can use the following snippet added to functions.php or any snippets plugin
// Apply CSS for B2B users only add_action('wp_head','b2b_only_css'); function b2b_only_css(){ // check that user is B2B if (get_user_meta(get_current_user_id(), 'b2bking_b2buser', true) === 'yes'){ ?> <style> .your_css_here{ background:red; } </style> <?php } } // Apply CSS for B2C and Logged Out users only add_action('wp_head','b2c_only_css'); function b2c_only_css(){ // check that user is not B2B if (get_user_meta(get_current_user_id(), 'b2bking_b2buser', true) !== 'yes'){ ?> <style> .your_css_here{ background:red; } </style> <?php } }
Powered by BetterDocs
Your email address will not be published. Required fields are marked *
Comment
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.