Benutzer automatisch basierend auf benutzerdefiniertem Feldwert zu Gruppen hinzufügen

Beim Erstellen einer Gruppe gibt es eine Einstellung für die automatische Mitgliedschaft basierend auf der E-Mail-Domain eines Benutzers. Ich würde diese Funktionalität jedoch basierend auf dem Wert eines benutzerdefinierten Feldes wünschen.

Anwendungsbeispiel

Ich habe eine Wohnungsgemeinschaft mit einem Dropdown-feld für den Eigentumsstatus (Eigentümer, Mieter). Ich möchte, dass alle Eigentümer automatisch einer Eigentümergruppe hinzugefügt werden und dass ich nur für bestimmte Nachrichten alle Eigentümer ansprechen kann.

Einschränkungen

Dies klingt für Dropdown- und Bestätigungsfelder unkompliziert, könnte aber bei Textfeldern kompliziert werden. Es wäre in Ordnung, dies nur für Dropdowns und Bestätigungen zu aktivieren; andernfalls ist eine exakte Textübereinstimmung für Textfelder ausreichend.

9 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

I’m looking to do something very similar to this for auto-segmenting users into groups based on a custom User Field dropdown. Did you happen to open-source this?

My use case is more or less the same, I asked about it here

3 „Gefällt mir“

@li-zi i know you kind of solved this for your case already, but it seems to me that one other potential solution is to use the Custom Wizard plugin.
I use this to prompt new users to fill out the wizard after signing up.
The wizard has some fields that offer dropdown options.
Then i set up two separate actions to complete after the wizard is submitted:

  • one to update the user profile custom fields with the wizard field from the drop down
  • another action to add user to specific group based on the wizard field selection
3 „Gefällt mir“

Um dies abzuschließen: Dies ist jetzt mit dem Automatisierungsskript „Benutzer über benutzerdefiniertes Feld zur Gruppe hinzufügen“ möglich. :partying_face:

Mehr darüber, wie das geht, erfahren Sie hier:

1 „Gefällt mir“