# Custom field in discourseconnect

**URL:** https://meta.discourse.org/t/custom-field-in-discourseconnect/219094
**Category:** Support
**Created:** [February 22, 2022, 7:31pm UTC](https://meta.discourse.org/t/custom-field-in-discourseconnect/219094 "2022-02-22T19:31:14Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Jay\_Moore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jay_moore/32/250843_2.png) [@Jay\_Moore](https://meta.discourse.org/u/Jay_Moore)
#### Post date: [February 22, 2022, 7:31pm UTC](https://meta.discourse.org/t/custom-field-in-discourseconnect/219094/1 "2022-02-22T19:31:14Z")

</div>

I am trying to pass a custom user field when signing on a user.

Here is the array I am signing…

```plaintext
$parameters = array(
            'nonce' => $nonce,
            'external_id' => 'jay',
            'email' => 'bugsbunny@betaclub.org',
            'username' => 'bugsbunny@betaclub.org',
            'name' => 'Bugs Bunny',
            'add_groups' => 'state_sponsors',
            'custom.experience' => 'Pro',
           'custom.state' => 'FL',
        );

```

The field name is Experience, it is a multiselect field and one of the options is Pro  
I am not seeing this come across? I also have a custom field named State, which is a Text Field. How do I troubleshoot this. I don’t see anything about the custom field in the logs with [discourse connect](https://meta.discourse.org/t/13045) logging turned on.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 22, 2022, 7:40pm UTC](https://meta.discourse.org/t/custom-field-in-discourseconnect/219094/2 "2022-02-22T19:40:24Z")

</div>

If you have created those fields via the Admin → Customize → User Fields, you need to pass it as

```plaintext
$parameters = array(
            'nonce' => $nonce,
            'external_id' => 'jay',
            'email' => 'bugsbunny@betaclub.org',
            'username' => 'bugsbunny@betaclub.org',
            'name' => 'Bugs Bunny',
            'add_groups' => 'state_sponsors',
            'custom.user_field_1' => 'Pro',
            'custom.user_field_2' => 'FL',
        );

```

The field names aren’t the name you set on the UI, but numbered fields named `user_field_NUMBER`.

---

<div class="post-metadata">

### Author: ![Jay\_Moore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jay_moore/32/250843_2.png) [@Jay\_Moore](https://meta.discourse.org/u/Jay_Moore)
#### Post date: [February 22, 2022, 8:02pm UTC](https://meta.discourse.org/t/custom-field-in-discourseconnect/219094/3 "2022-02-22T20:02:57Z")

</div>

That worked thanks so much.

Do you know how to populate a multi select field with multiple values?

‘custom.user\_field\_1’ =\> ‘Pro, Newbie’,

??

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 22, 2022, 8:36pm UTC](https://meta.discourse.org/t/custom-field-in-discourseconnect/219094/4 "2022-02-22T20:36:41Z")

</div>

Curiously I was looking into this last week, and from the looks of it we do _not_ support multi select fields via the [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) payload at the moment.

---

<div class="post-metadata">

### Author: ![Jay\_Moore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jay_moore/32/250843_2.png) [@Jay\_Moore](https://meta.discourse.org/u/Jay_Moore)
#### Post date: [February 24, 2022, 12:39pm UTC](https://meta.discourse.org/t/custom-field-in-discourseconnect/219094/7 "2022-02-24T12:39:05Z")

</div>

Did some testing and it will populate a multi select field if only a single value is sent.  
Does not work - ‘custom.user\_field\_1’ =\> ‘Pro, Newbie’,  
Does work - ‘custom.user\_field\_1’ =\> ‘Pro’,

This is OK for our needs. If that field is editable by the end user they can add other selections as needed.

@Falco Thanks so much for the help

---

<div class="post-metadata">

### Author: ![Jay\_Moore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jay_moore/32/250843_2.png) [@Jay\_Moore](https://meta.discourse.org/u/Jay_Moore)
#### Post date: [February 24, 2022, 2:16pm UTC](https://meta.discourse.org/t/custom-field-in-discourseconnect/219094/8 "2022-02-24T14:16:26Z")

</div>

Next question is about add\_groups. I have a comma delimited list, but it is not adding user to the groups.

```plaintext
$parameters = array(
            'nonce' => $nonce,
            'external_id' => $sponsor['spid'],
            'email' => $sponsor['email'],
            'username' => $sponsor['email'],
            'name' => $fullname,
            'add_groups' => 'state_sponsor, status_sponsor, elect_sponsor',
            'location' => $location,
            'custom.user_field_1' => $experience, //experience - Newbie, Less than 5, Pro, Old Timer
            'custom.user_field_2' => $club['name'].' ('.$sponsor['new_id'].')', //school name with clubid
            'custom.user_field_4' => $division, //division
        );

```

The payload reported is:

```plaintext
add_groups=state_sponsor%2C+status_sponsor%2C+elect_sponsor
email=xxxx%40spart1.org
external_id=xxxx
name=Angela+Moore
nonce=xxxx
username=xxxx%40spart1.org
location=Landrum%2C+SC
custom.user_field_1=Pro
custom.user_field_2=Landrum+Middle+School+%28JSC0081%29
custom.user_field_4=Junior

```

In the logs for discouseconnect I see:

```plaintext
add_groups: state_sponsor, status_sponsor, elect_sponsor
admin: 
moderator: 
avatar_force_update: 
avatar_url: 
bio: 
card_background_url: 
email: xxxx@spart1.org
external_id: xxxxx
groups: 
locale: 
locale_force_update: 
logout: 
name: Angela Moore
nonce: xxxx
profile_background_url: 
remove_groups: 
require_activation: 
return_sso_url: 
suppress_welcome_message: 
title: 
username: xxxx@spart1.org
website: 
location: Landrum, SC

```

Which looks correct.  
I would like to add this user to the ‘state\_sponsor, status\_sponsor, elect\_sponsor’ groups.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 24, 2022, 5:54pm UTC](https://meta.discourse.org/t/custom-field-in-discourseconnect/219094/9 "2022-02-24T17:54:38Z")

</div>

> [@Jay\_Moore](#):
>
> ` 'add_groups' => 'state_sponsor, status_sponsor, elect_sponsor',`

You need to drop the space between the commas.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [March 26, 2022, 6:01pm UTC](https://meta.discourse.org/t/custom-field-in-discourseconnect/219094/11 "2022-03-26T18:01:33Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
