عند إنشاء مجموعة، يتوفر لدينا إعداد العضوية التلقائي بناءً على نطاق بريد المستخدم الإلكتروني. أود الحصول على هذه الوظيفة بناءً على قيمة حقل مخصص.
مثال على حالة الاستخدام
لدي مجتمع سكني (كوندو) يحتوي على حقل مخصص من نوع القائمة المنسدلة يشير إلى حالة الملكية (مالك، مستأجر). أريد أن يكون جميع المالكين تلقائيًا ضمن مجموعة المالكين، وأن أتمكن من مراسلة جميع المالكين فقط لبعض الرسائل.
محاذير
يبدو هذا الأمر مباشرًا بالنسبة للحقول المخصصة من نوع القائمة المنسدلة وحقول التأكيد، لكنني أتوقع أن يصبح الأمر معقدًا بالنسبة لحقول النص. سيكون مقبولًا تمكين هذه الوظيفة فقط للقوائم المنسدلة وحقول التأكيد، وإلا فإن المطابقة النصية الدقيقة ستكون كافية لحقول النص.
Since these are user settable custom fields, you can just make the groups open membership and tell people to add / remove themselves via the /groups page.
Not realistic for my use case. Hard to get a bunch of random homeowners, some very old, to bother going around tinkering with their settings. It was hard enough getting them to just register once to get the emails, and it’s hard to even get them to pay attention and do stuff even when there are financial penalties.
For anybody coming across this in the future: I had a similar use case (two distinct user populations – people offering services vs. people seeking services) and ended up implementing it via webhooks and the Discourse API.
More specifically, I…
created a webhook triggered on user events
implemented a barebones Express.js server to receive the payload
set up a POST route for user_created events that checks the value of a custom user field, and then uses the Discourse API to set the user’s group accordingly
This seems like kind of a goofy way to do it because I’m going outside Discourse to modify something within Discourse, but I scoured the forum for answers to this and came up with nothing, so I did my best! Hope this helps someone in the future, and if anyone comes up with a better way of doing it, I’d love to know.
@li-zi أعلم أنك قد حللت هذه المشكلة إلى حد ما لحالتك بالفعل، لكن يبدو لي أن هناك حلاً محتملاً آخر يتمثل في استخدام إضافة السحر المخصص.
أستخدم هذه الإضافة لتذكير المستخدمين الجدد بإكمال السحر بعد التسجيل.
يحتوي السحر على بعض الحقول التي تقدم خيارات منسدلة.
ثم قمت بإعداد إجراءين منفصلين للتنفيذ بعد تقديم السحر:
أحدهما لتحديث حقول ملف المستخدم المخصصة باستخدام حقل السحر من القائمة المنسدلة
وإجراء آخر لإضافة المستخدم إلى مجموعة محددة بناءً على اختيار حقل السحر
لإنهاء هذا الأمر - أصبح هذا ممكنًا الآن باستخدام البرنامج النصي للأتمتة ‘إضافة مستخدم إلى مجموعة من خلال حقل مخصص’.
يمكنك قراءة المزيد حول كيفية القيام بذلك هنا: