Skip to Content Skip to Menu

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

CB Fields in Plugin

  • gravesie
  • gravesie
  • OFFLINE
  • Posts: 19
  • Thanks: 2
  • Karma: 0
11 years 6 months ago #225456 by gravesie
CB Fields in Plugin was created by gravesie
Hi

I have created a CB Plugin to display information depending on a condition, this works fine.

I am trying to replicate the User Status information that can be viewed on a profile e.g Online Status, Member Since etc. I have found the tutorial on retrieving CBfields and am using $cbUser->getField('registerDate', null, 'html', 'none', 'list'); to get one of the fields but this is not returning anything. The $cbUser array is populated.

Is there any way I can include all the User Status info or include parts of it?

Thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
11 years 6 months ago #225474 by krileon
Replied by krileon on topic CB Fields in Plugin
getField usage is the correct usage. Although you may not want the userlist display of the field and instead want profile view. Note API respect access and display permissions so if the field isn't set to display on profile for example then the getField API usage also won't display it. Some usages as follows.

Establish cbUser
Code:
$cbUser =& CBuser::getInstance( (int) $userId ); if ( ! $cbUser ) { $cbUser =& CBuser::getInstance( null ); }

Linked Avatar Thumbnail
Code:
$avatar = $cbUser->getField( 'avatar', null, 'html', 'none', 'list', 0, true )

Linked Format Name
Code:
$name = $cbUser->getField( 'formatname', null, 'html', 'none', 'list', 0, true );

HTML Online Status (icon, etc..)
Code:
$online = $cbUser->getField( 'onlinestatus', null, 'html', 'none', 'profile', 0, true );


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.

  • gravesie
  • gravesie
  • OFFLINE
  • Posts: 19
  • Thanks: 2
  • Karma: 0
11 years 6 months ago #225526 by gravesie
Replied by gravesie on topic CB Fields in Plugin
Thanks for your reply

I had the $cbUser field defined already but checked it held a value, it does.

I used your example of $online = $cbUser->getField( 'onlinestatus', null, 'html', 'none', 'profile', 0, true );

$cbUser is populated and when stepping through the script the value of $online is string = "-". I stepped into function getField in plugin.foundation.php the return $value is string = "-".
In this method $tabs is populated, $fields[0] is populated, £field is populated, but after S_PLUGINS->callField is called the $value is string = "-".

Any ideas?

Thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
11 years 6 months ago #225547 by krileon
Replied by krileon on topic CB Fields in Plugin
The field needs to be set to display on profile. It also needs to be on a published and public CB tab. It should then work fine. Fields API and substitutions always respect configuration, privacy settings, and access permissions. The API usage is correct, I don't know what more to advise.


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.

  • gravesie
  • gravesie
  • OFFLINE
  • Posts: 19
  • Thanks: 2
  • Karma: 0
11 years 6 months ago #225982 by gravesie
Replied by gravesie on topic CB Fields in Plugin
Hi

I have tried the avatar and name fields and these work fine, it is just the onlinestatus that does not return anything.

Thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
11 years 6 months ago #225993 by krileon
Replied by krileon on topic CB Fields in Plugin
The exact usage I've provided you is working fine in GJ and many other incubator projects. The only reason for it to not work is if the field isn't set to display on profile and isn't on a tab that is accessible. So it must be set to display on profile and be on a public and published tab (tab can be in a not shown on profile position though). Sorry, I don't know what to advise as its usage is confirmed working; there must be a configuration issue somewhere.


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: gravesie

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

Moderators: beatnantkrileon
Powered by Kunena Forum