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
Per memorizzare i dati personalizzati su Discourse, sono andato su Amministratore > Personalizza > Campi utente e ho creato un campo personalizzato. I dati di cui avevo bisogno erano una percentuale che rappresentava il progresso, quindi ho scelto “testo” come tipo di campo. Il nome del campo viene visualizzato solo sulla scheda e nel profilo dell’utente e, purtroppo, non viene utilizzato per fare riferimento programmaticamente ai dati del campo.
Il campo che memorizza il progresso era il terzo campo personalizzato che avevo creato, quindi “3” diventa un numero molto importante.
Utilizzando l’API, ho scritto uno script curl (con l’aiuto di https://meta.discourse.org/t/api-cannot-update-user/63876/4) per popolare il campo con dati di prova. Poiché il campo che volevo popolare era il terzo che avevo creato, la riga dei dati nel mio script curl è:
--data '{ "user_fields": { "3":"87" } }'
Per visualizzare i dati, è stato necessario andare su Amministratore > Impostazioni > Utenti, scorrere fino all’opzione “campi utente personalizzati pubblici” e inserire il campo nella whitelist. Poiché il campo era il terzo creato, ho dovuto inserire nella whitelist “user_field_3” e non il nome effettivo che avevo dato al campo.
A questo punto, ho scritto un plugin di base con il seguente codice: