Documentation

onGetUserFieldValues

Called every time when receiving user fields in the method \CUserTypeManager::getUserFieldValuesByEvent()

Parameters

Parameter Description Available from version
array userFields Array of descriptions for user fields, where key - field name.
string entityId Entity string-identifier (for example, UF_USR for user)
int $value Entity ID (for example, user ID)

Return value

Event handler must return array containing user field values and with the key - field name. When values are not passed, the values will be received via the "old" way, from corresponding tables.

Example

\Bitrix\Main\EventManager::getInstance()->addEventHandler('main', 'onGetUserFieldValues', function(\Bitrix\Main\Event $event)
{
   $result = new \Bitrix\Main\EventResult(\Bitrix\Main\EventResult::SUCCESS);

   $entityId = $event->getParameter('entityId');
   $userFields = $event->getParameter('userFields');
   $value = $event->getParameter('value');

   if($entityId === 'UF_MY_ENTITY')
   {
      $values = [
         'UF_MY_ENTITY_FIELD' => 'someValue',
      ];

      $result = new \Bitrix\Main\EventResult(\Bitrix\Main\EventResult::SUCCESS, [
         'values' => $values,
      ]);
   }

   return $result;
});


© «Bitrix24», 2001-2024
Up