カスタムフィールドの値に基づいてユーザーを自動的にグループに追加

グループ作成時に、ユーザーのメールアドレスドメインに基づいた自動メンバーシップ設定を設けています。この機能を、カスタムフィールドの値に基づいて行えるようにしたいと考えています。

使用例

オーナーかテナントかを示すドロップダウン形式のカスタムフィールドがあるコンドミニアムコミュニティを想定しています。すべてのオーナーを自動的にオーナーグループに含め、特定のメッセージについてはオーナーのみを対象に送信できるようにしたいです。

留意点

ドロップダウンや確認用のカスタムフィールドであれば straightforward な機能ですが、テキストフィールドの場合は複雑になる可能性があります。そのため、ドロップダウンと確認フィールドにのみこの機能を有効化し、テキストフィールドの場合は完全一致によるマッチングで問題ありません。

「いいね!」 9

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.

「いいね!」 2

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.

「いいね!」 1

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.

「いいね!」 3

カスタムユーザーフィールドのドロップダウンに基づいて、ユーザーをグループに自動セグメント化する際、これと非常に似たことを行おうとしています。このコードはオープンソース化されましたか?

私のユースケースはほぼ同じで、こちらで質問しました

「いいね!」 3

@li-zi、あなたのケースについては既におおよそ解決されているようですが、もう一つの可能性として、Custom Wizard プラグインを使用する方法があるかもしれません。
私はこのプラグインを使って、新規ユーザーがサインアップした後にウィザードの入力を促しています。
このウィザードには、ドロップダウンオプションを提供するフィールドがいくつかあります。
その後、ウィザードが送信された後に実行される2つの別々のアクションを設定しました。

  • 1つ目は、ウィザードのドロップダウンから選択された値でユーザープロフィールのカスタムフィールドを更新するアクション
  • 2つ目は、ウィザードのフィールド選択に基づいてユーザーを特定のグループに追加するアクションです。
「いいね!」 3

これでこの件は完了です。これは、「Add user to group through custom field」という自動化スクリプトを使用して可能になりました。:partying_face:

その方法については、こちらで詳しく読むことができます。

「いいね!」 1