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
Para armazenar os dados personalizados no Discourse, fui em Admin > Personalizar > Campos de Usuário e criei um campo personalizado. Os dados que preciso são um percentil representando o progresso, e escolhi “texto” como tipo de campo. O nome do campo é exibido apenas no cartão e no perfil do usuário e, infelizmente, não é usado para referenciar programaticamente os dados do campo.
O campo que armazena o progresso foi o terceiro campo personalizado que criei, portanto, “3” se tornou um número muito importante.
Usando a API, escrevi um script curl (com a ajuda de https://meta.discourse.org/t/api-cannot-update-user/63876/4) para preencher o campo com dados de teste. Como o campo que eu queria preencher era o terceiro que criei, minha linha de dados no script curl é:
--data '{ "user_fields": { "3":"87" } }'
Para exibir os dados, foi necessário ir em Admin > Configurações > Usuários, rolar até a opção “campos personalizados públicos de usuário” e adicionar o campo à lista branca. Como o campo foi o terceiro criado, tive que adicionar “user_field_3” à lista branca e não o nome real que dei ao campo.
Neste ponto, escrevi um plugin básico com o seguinte código: