Finding Userfield Custom Name for 'Add user to group through User Custom Field'

Hi @leonardo I’m also having some issue with the Add user to group through User Custom Field .

Plugin is installed

I have the custom user field setup with 2 dropdown options (Teacher, Parent)

So I created a recurring Automation that should add Teacher to the Teacher group + Parent to the Parent Group.

It’s set to run every 1 minute.

Any thoughts? :pray:

Hi Andy!

One of our hosted customers also recently asked a question about how exactly to configure the Add user to group through User Custom Field automation. I’m putting a generic version of the answer here for the benefit of our wider ecosystem, as the UX is admittedly not very friendly at the moment - apologies for that while we work to improve it.

How to set up the Add user to group through User Custom Field Automation script

First you need to create a user field from Customize → User Fields (of type Dropdown per the above discussion), then figure out the UserCustomField name (as opposed to the UserField name which is the “template” for the field), and point the Automation script to that field name.

To unpack the related part of the data model: the Admin → Customize → User Fields view shows a list of UserField records (ie. “user field templates”). When you create a record here, users will subsequently be able to choose a value for that when they signup or from their profile. That value will be stored as a new UserCustomField record (ie. “user field instances”, or “actual user fields for users”) linked to the particular User ID, and this record in turn has a synthethic name constructed as user_field_#{user_field_id}.

That is, suppose your new UserField has a name of Another UserField:

(you can see this JSON view from /admin/customize/user_fields.json for your site)

Look for the record with the name of your UserField, and observe its ID, and add that to user_field_NUMBER to get the name value that the UserCustomFields will take, and that is what you need to configure in the User Custom Field value in the script.

Apologies for the carnage; these are provisional instructions until we improve the UX.

3 Likes

Hi @team

Having installed the automation plugin, I can see that there is a trigger for being promoted between trust levels. Is there a way to trigger an action based on demotion, specifically TL3 to TL2?

Thanks, Dan

1 Like

Gratitude @leonardo !

Just to clarify:

Look for the record with the name of your UserField , and observe its ID, and add that to user_field_NUMBER to get the name value that the UserCustomFields will take, and that is what you need to configure in the User Custom Field value in the script.

Where do I add that to user_field_NUMBER ?

This is my view when setting up the plugin in discourse:

This is the data from the custom field:

I’ll test this and see if it works. Thanks again for the support!

There’s only one user field present in that output, with ID 1, so you would set the User Custom Field Name field to user_field_1 instead of 1 as you currently have it.

As of today, I’m afraid the trigger explicitly checks for demotions and avoids firing - it only works for promotions:

3 Likes

Thanks for this @leonardo. Would it be a huge undertaking to add TL3 to TL2? I’m not sure who the best person to request this from is? It is the only automatic demotion that occurs and it would be really useful to be able to take action with the plugin based on this.