Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

How to register User custom field using PHP?

Avatar

Level 2

Hi!

I am looking for a way to share user specific data between connected users. For example, all participants should know each other IDs(our own system IDs, not LCCS).

User's custom fields looks the best solution for this, but I can't find a way to register one using PHP, while creating room.

How to register User's  custom field using PHP? Or may be there are better solution to make such things?

1 Accepted Solution

Avatar

Correct answer by
Level 2

Got it, just need to add new node to UserManager collection.

const USER_MANAGER_COLLECTION = 'UserManager';

static private $USER_MANAGER_CUSTOM_FIELD_CONFIGURATION = array(

   'accessModel'=>self::ROLE_VIEWER,

   'publishModel'=>self::ROLE_VIEWER,

   'persistItems'=>true,

   'modifyAnyItem'=>false,

   'userDependentItems'=>true,

   'sessionDependentItems'=>false,

   'itemStorageScheme'=>self::STORAGE_SCHEME_MANUAL,

   'allowPrivateMessages'=>true,

   'lazySubscription'=>false,

   'p2pDataMessaging'=>false

);

const USER_INVITE_ID_CUSTOM_FIELD = 'inviteId';

static private function createUserManagerCustomFields($room){

   $account = self::init();

   $collection = self::USER_MANAGER_COLLECTION;

   $account->subscribeCollection($room, $collection);

   $account->createNode($room, $collection, self::USER_INVITE_ID_CUSTOM_FIELD, self::$USER_MANAGER_CUSTOM_FIELD_CONFIGURATION);

}

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

Got it, just need to add new node to UserManager collection.

const USER_MANAGER_COLLECTION = 'UserManager';

static private $USER_MANAGER_CUSTOM_FIELD_CONFIGURATION = array(

   'accessModel'=>self::ROLE_VIEWER,

   'publishModel'=>self::ROLE_VIEWER,

   'persistItems'=>true,

   'modifyAnyItem'=>false,

   'userDependentItems'=>true,

   'sessionDependentItems'=>false,

   'itemStorageScheme'=>self::STORAGE_SCHEME_MANUAL,

   'allowPrivateMessages'=>true,

   'lazySubscription'=>false,

   'p2pDataMessaging'=>false

);

const USER_INVITE_ID_CUSTOM_FIELD = 'inviteId';

static private function createUserManagerCustomFields($room){

   $account = self::init();

   $collection = self::USER_MANAGER_COLLECTION;

   $account->subscribeCollection($room, $collection);

   $account->createNode($room, $collection, self::USER_INVITE_ID_CUSTOM_FIELD, self::$USER_MANAGER_CUSTOM_FIELD_CONFIGURATION);

}