Fetching field value of a specific user from text area of an CB Content Module

4 years 10 months ago #312311 by MMDoege
In a CB Content Module I'd like to use a cb:if substitution to verify if the content owner is not viewing the module and if content owner has allowed his contact data to be displayed to all other viewing users.

Of course the code below does not work properly as "the module" picks the current value of cb_download_display_gallery_contact_toggle from each user viewing the module and not that of the content owner's profile (in this case user 255). What can I do to accomplish this? Can I use any type of asset, say field.34.userid.255 ?

Code:

[cb:if user_id !="255" and cb_download_display_gallery_contact_toggle="1"]
[cb:userfield field="avatar" user="255" reason="list" /]
[/cb:if]

Thanks in advance.

Please Log in to join the conversation.

4 years 10 months ago #312313 by krileon
Something like that will only work if the module is displayed on the users profile and you're viewing that users profile. If that's the case you should be able to use user="#displayed" and user="#me" to toggle between who you're checking against. If it's not being displayed on profile then you'll have to do as you're doing and hardcode in the user id. In your case the below should work to check the field value of cb_download_display_gallery_contact_toggle for 255.

[cb:if user="255" cb_download_display_gallery_contact_toggle="1"]CONTENT_HERE[/cb:if]

If you don't want this to display to user 255 then you need to nest 2 different IF checks like the following.

[cb:if user_id!="255"][cb:if user="255" cb_download_display_gallery_contact_toggle="1"]CONTENT_HERE[/cb:if][/cb:if]

That should check if the viewing user is 255 and if they are display nothing. If they aren't then check the field value of cb_download_display_gallery_contact_toggle for user 255. If this is being used on a users profile you can use the below to avoid hardcoding user id.

[cb:if user="#displayed" user_id!="myid"][cb:if user="#displayed" cb_download_display_gallery_contact_toggle="1"]CONTENT_HERE[/cb:if][/cb:if]

That should ensure the viewing user is not the displayed user then check the value of cb_download_display_gallery_contact_toggle for the displayed user. Please keep in mind though #displayed does not function anywhere except on a users profile.


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.
The following user(s) said Thank You: MMDoege

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.254 seconds

Facebook Twitter LinkedIn