Skip to Content Skip to Menu

Using CB avatars in other applications

8 hours 3 minutes ago #341987 by counterpoint
Using CB avatars in other applications was created by counterpoint
I'm the maintainer of UserPoints, which displays user avatars in some situations. Users are asking if the option to use CB avatars can be supported. Old code to do this is clearly obsolete. What is the up to date way to obtain a user's CB avatar please?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 49560
  • Thanks: 8483
  • Karma: 1465
7 hours 30 minutes ago #341992 by krileon
Replied by krileon on topic Using CB avatars in other applications
That's done using our fields API.

www.joomlapolis.com/documentation/127-community-builder/279-tutorials/18361-obtaining-field-values-through-getfields-api

You'd just be pulling in their avatar field for rendering. Profile view is full size image of the avatar without profile link. List view is thumbnail size of the image with profile link, but that can be turned off. Below are some examples.

Full Size (No Link):
Code:
CBuser::getInstance( USER_ID_HERE, false )->getField( 'avatar' );

Thumbnail (With Link)
Code:
CBuser::getInstance( USER_ID_HERE, false )->getField( 'avatar', null, 'html', 'none', 'list', 0, true );

Thumbnail (Without Link)
Code:
CBuser::getInstance( USER_ID_HERE, false )->getField( 'avatar', null, 'html', 'none', 'list', 0, true, [ '_allowProfileLink' => false ] );

Replace USER_ID_HERE with the user id you're trying to get the avatar for. Note you need to first include CBs API as shown below for external usage.

www.joomlapolis.com/documentation/127-community-builder/279-tutorials/18357-including-cb-api-for-usage-outside-of-cb


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.

6 hours 33 minutes ago - 6 hours 18 minutes ago #341996 by counterpoint
Replied by counterpoint on topic Using CB avatars in other applications
Thanks very much for that.
Last edit: 6 hours 18 minutes ago by counterpoint. Reason: Mistake

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

6 hours 19 minutes ago - 6 hours 17 minutes ago #341997 by counterpoint
Replied by counterpoint on topic Using CB avatars in other applications
:)
Last edit: 6 hours 17 minutes ago by counterpoint. Reason: Irrelevant

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

Moderators: beatnantkrileon
Powered by Kunena Forum