Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] CB Substitution in articles: How to hide a tab if the owner is a Super User OR a Publisher?

  • ricco1
  • ricco1
  • OFFLINE
  • Posts: 310
  • Thanks: 8
  • Karma: -7
11 years 3 weeks ago - 11 years 3 weeks ago #235013 by ricco1
Hi,

I'm using CB Substitutions to insert the Contact Info tab in the articles, so far I've achieved what I needed with this code:

{cb:[cb:usertab tab="11" output="html" formatting="table" reason="profile" /]}

What I need now is to be able to hide the above tab if the author of the article is a Super User or a Publisher.

My Viewing Access Levels are set like this:

"Spacial" with id 3 = "Super Users" and "Publishers"
"Super Users" with id 5 = "Super Users"

My "Super User" User Group is with id 8 and my "Publisher" User Group is with id 5.

I think I've managed to achieve what I want by the following:

{cb:[cb:if viewaccesslevel !includes "3" || !includes "5"][cb:usertab tab="11" output="html" formatting="table" reason="profile" /][/cb:if]}

BUT I'm not sure if I'm using the right code.

I've searched a lot but I couldn't find how to use properly the "or" operator in case of multiple values, e.g.:

viewaccesslevel !includes "3" || !includes "5"

viewaccesslevel !includes "3||5"

viewaccesslevel !includes "3|5"

viewaccesslevel !includes "3" || viewaccesslevel !includes "5"

viewaccesslevel !=~"/3|5/"


Is it better to use the "includes" operator or the regex?

Is better to use the "viewaccesslevel" or the "gids" ?

Could you correct me if I'm making a mistake please?

Thank you
Best regards
Last edit: 11 years 3 weeks ago by krileon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48471
  • Thanks: 8280
  • Karma: 1443
11 years 3 weeks ago #235018 by krileon
The below is the correct usage, but I've no idea how well the viewaccesslevel checks will work using the or operator.

[cb:if viewaccesslevel !includes "3" or viewaccesslevel !includes "5"]
[cb:usertab tab="11" output="html" formatting="table" reason="profile" /]
[/cb:if]


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • ricco1
  • ricco1
  • OFFLINE
  • Posts: 310
  • Thanks: 8
  • Karma: -7
11 years 3 weeks ago - 11 years 3 weeks ago #235035 by ricco1
Hi Kyle,

Thank you for your quick response.

Could you instead tell me how to hide the tab with the usage of "user_id" as I will not have many publishers I think it will be much easier.

Let's say I have 2 publishers with ID's 123 and 214, also as I have some articles who's authors are deleted so it will show as an article with author's ID 0.

I've tried the below code but it's not working to hide the tab in the articles in case the authors are with ID's 123, 214, 0:

[cb:if user_id!="123" or user_id!="214" or user_id!="0"]
[cb:usertab tab="11" output="html" formatting="table" reason="profile" /]
[/cb:if]

For now I'm using:

[cb:if viewaccesslevel !includes "3"]
[cb:usertab tab="11" output="html" formatting="table" reason="profile" /]
[/cb:if]

I suppose I don't need to use the or operator as my Viewing Access Level "Spacial" with id 3 includes both "Super Users" and "Publishers".

Thank you again
You are grate
Last edit: 11 years 3 weeks ago by ricco1.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48471
  • Thanks: 8280
  • Karma: 1443
11 years 3 weeks ago - 11 years 3 weeks ago #235094 by krileon
Navigate to Extensions > Plug-in Manager > Content - Community Builder and ensure under Basic you have User set to Author and not the Viewer. It defaults to Viewer, which causes all substitutions to be based off the user viewing the article and not who wrote it.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 11 years 3 weeks ago by krileon.

Please Log in or Create an account to join the conversation.

  • ricco1
  • ricco1
  • OFFLINE
  • Posts: 310
  • Thanks: 8
  • Karma: -7
11 years 3 weeks ago #235109 by ricco1
Hi,

It is already set to Author, I haven't changed it.

Anyway I think it's working now with the below:

[cb:if viewaccesslevel !includes "3"]
[cb:usertab tab="11" output="html" formatting="table" reason="profile" /]
[/cb:if]

so better not mess it.

Thank you
Have nice day
The following user(s) said Thank You: krileon

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum