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
لتخزين البيانات المخصصة على Discourse، ذهبت إلى Admin > Customize > User Fields وأنشأت حقلًا مخصصًا. البيانات التي أحتاجها هي نسبة مئوية تمثل التقدم، وقد اخترت “text” كنوع للحقل. يُعرض اسم الحقل فقط على بطاقة المستخدم وصفحته الشخصية، وللأسف لا يُستخدم للإشارة إلى بيانات الحقل برمجياً.
كان الحقل الذي يخزن التقدم هو الحقل المخصص الثالث الذي أنشأته، وبالتالي أصبح الرقم “3” رقمًا مهمًا جدًا.
باستخدام واجهة برمجة التطبيقات (API)، كتبت سكريبت curl (بمساعدة https://meta.discourse.org/t/api-cannot-update-user/63876/4) لملء الحقل ببيانات تجريبية. وبما أن الحقل الذي أردت ملؤه كان الحقل الثالث الذي أنشأته، فإن سطر البيانات في سكريبت curl هو:
--data '{ "user_fields": { "3":"87" } }'
أما لعرض البيانات، فقد تطلّب الأمر الذهاب إلى Admin > Settings > Users، والتمرير إلى خيار “public user custom fields” وإدراج الحقل في القائمة البيضاء. وبما أن الحقل كان الثالث الذي تم إنشاؤه، فقد اضطررت لإدراج “user_field_3” في القائمة البيضاء وليس الاسم الفعلي الذي أعطيته للحقل.
في هذه المرحلة، كتبت إضافة أساسية تحتوي على ما يلي: