I am trying to display some externally generated user data below the user’s avatar. Currently, the data is stored in a custom user field of type ‘text’ and the field is populated via an API call as well as during SSO.
Now I am trying to determine the best way to actually display the data. Actually, I’m trying to find any way to display the data. A plugin seems like the best option, but there is no plugin-outlet that can be used.
Can someone with more knowledge point me in the correct direction?
Thank you, that has certainly helped with displaying data in the correct location. Unfortunately it has also led me to another stumbling block.
From the helper.attrs, I can get the username and the user_id. Using this info, I then tried:
Discourse.User.findByUsername(helper.attrs.username).then((user)=>{
let f1_val = user.user_fields[1];
return helper.h('div', `${f1_val}`);
});
Aside from throwing an error, this method of data retrieval results in an API request for every post. Is there a way to access the information from the Ember side without requiring an API call?
Would you mind sharing the basic idea of what ended up working for you? I’m curious what you ended up going with and I’m sure others that happen upon this topic will appreciate the info as well
In order to store the custom data on Discourse, I went to Admin > Customize > User Fields and created a custom field. The data I need is a percentile representing progress and I chose “text” as the field type. The field’s name is only displayed on the user’s card and profile and is sadly not used to reference the field data programatically.
The field storing the progress was the 3rd custom field I created and thus “3” becomes a very important number.
Using the API, I wrote a curl script (with the help of https://meta.discourse.org/t/api-cannot-update-user/63876/4) to populate the field with test data. Because the field I wanted to populate was the 3rd field I created, my data line in the curls script is:
--data '{ "user_fields": { "3":"87" } }'
Displaying the data required going to Admin > Settings > Users, and scrolling to the “public user custom fields” option and whitelisting the field. Since the field was the 3rd created, I had to whitelist “user_field_3” and not the actual name I gave the field.
At this point, I wrote a basic plugin with the following: