DiscourseConnect のカスタムフィールド

ユーザーをサインオンする際にカスタムユーザーフィールドを渡そうとしています。

以下はサインオンしている配列です…

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

フィールド名はExperienceで、マルチセレクトフィールドであり、オプションの1つはProです。
これは反映されていませんか?また、Stateというカスタムフィールドもあり、これはテキストフィールドです。どのようにトラブルシューティングすればよいですか?Discourse Connectのロギングを有効にしても、ログにカスタムフィールドに関するものは何も表示されません。

Admin → Customize → User Fields からそれらのフィールドを作成した場合、次のように渡す必要があります。

$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',
        );

フィールド名はUIで設定した名前ではなく、user_field_NUMBER という名前の番号付きフィールドになります。

「いいね!」 5

うまくいきました、本当にありがとうございます。

マルチセレクトフィールドに複数の値を設定する方法を知っていますか?

‘custom.user_field_1’ => ‘Pro, Newbie’,

??

「いいね!」 1

不思議なことに、先週この件を調べていたのですが、どうやら現時点では DiscourseConnect ペイロード経由で複数選択フィールドをサポートしていないようです。

テストを行ったところ、単一の値が送信された場合でもマルチセレクトフィールドが設定されることがわかりました。
機能しない例: ‘custom.user_field_1’ => ‘Pro, Newbie’
機能する例: ‘custom.user_field_1’ => ‘Pro’

これは私たちのニーズには合っています。もしそのフィールドがエンドユーザーによって編集可能であれば、必要に応じて他の選択肢を追加できます。

@Falco 協力いただき大変ありがとうございました。

「いいね!」 1

次の質問は add_groups についてです。カンマ区切りのリストがありますが、ユーザーがグループに追加されません。

$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
        );

報告されたペイロードは次のとおりです。

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

discourseconnect のログには次のように表示されます。

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

これは正しく見えます。
このユーザーを「state_sponsor、status_sponsor、elect_sponsor」グループに追加したいと思います。

コンマの間のスペースを削除する必要があります。

「いいね!」 1

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