我正在尝试在用户登录时传递自定义用户字段。
这是我正在登录的数组…
$parameters = array(
'nonce' => $nonce,
'external_id' => 'jay',
'email' => 'bugsbunny@betaclub.org',
'username' => 'bugsbunny@betacoil.org',
'name' => 'Bugs Bunny',
'add_groups' => 'state_sponsors',
'custom.experience' => 'Pro',
'custom.state' => 'FL',
);
字段名称是 Experience,它是一个多选字段,其中一个选项是 Pro。
我没有看到这个字段传递过来?我还有一个名为 State 的自定义字段,它是一个文本字段。我该如何排除故障。在开启 Discourse Connect 日志记录的情况下,我在日志中没有看到任何关于自定义字段的信息。
Falco
(Falco)
2
如果您通过“管理”->“自定义”->“用户字段”创建了这些字段,则需要将其传递为
$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 个赞
太好了,非常感谢。\n\n您知道如何用多个值填充多选字段吗?\n\n’custom.user_field_1’ => ‘Pro, Newbie’,\n\n??
1 个赞
Falco
(Falco)
4
奇怪的是,我上周一直在研究这个问题,从目前来看,我们不支持通过 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”组。
system
(system)
关闭
11
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.