Documentation

onUpdateUserFieldValues

Parameters

Parameter Description Available from version
string entityId Entity string-identifier (for example, UF_USR for user)
int $id Entity identifier (for example, user ID)
array fields User field values, where key - field name

Event handler can return object \Bitrix\Main\EventResult with type:

  • \Bitrix\Main\EventResult::SUCCESS on successful writing of new values
  • \Bitrix\Main\EventResult::ERROR, when errors occurred during update

When event was caught, but update didn't occur, you must return the object \Bitrix\Main\EventResult with the type \Bitrix\Main\EventResult::UNDEFINED/

Example

\Bitrix\Main\EventManager::getInstance()->addEventHandler('main', 'onUpdateUserFieldValues', function(\Bitrix\Main\Event $event)
{
   $resultType = \Bitrix\Main\EventResult::UNDEFINED;

   $entityId = $event->getParameter('entityId');
   $fields = $event->getParameter('fields');
   $id = $event->getParameter('id');

   if($entityId === 'UF_MY_ENTITY')
   {
      //update data
      $result = \MyModule\Model\SomeStorageTable::update($id, $fields);
      if($result->isSuccess())
      {
         $resultType = \Bitrix\Main\EventResult::SUCCESS;
      }
      else
      {
         $resultType = \Bitrix\Main\EventResult::ERROR;
      }
   }

   return new \Bitrix\Main\EventResult($resultType);
});


© «Bitrix24», 2001-2024
Up