Documentation

onBeforeResultStatusChange

Description and parameters

handler function(
 int WEB_FORM_ID,
 int RESULT_ID,
 int &NEW_STATUS_ID,
 string(1) CHECK_RIGHTS
);
Event handlers are called before updating status for webform result. This can be used for any additional checks or even for updating new status, as well as for replacing webform status handler. Handler is not designed to return any values. Errors can be returned via $APPLICATION->ThrowException().

Parameters

ParameterDescription
WEB_FORM_ID Webform ID.
RESULT_ID Result ID.
NEW_STATUS_ID Status ID.
CHECK_RIGHTS Flag "Check access permissions" (Y|N).

See Also

Handler function example

public static function my_onBeforeResultStatusChange($WEB_FORM_ID, $RESULT_ID, $NEW_STATUS_ID, $CHECK_RIGHTS)
{
  global $USER;
  
  // handler action applies only to the webform with ID=6
  if ($WEB_FORM_ID == 6) 
  {
    // 1 - "checked" status (by default), 2 - "accepted" status
    // result, sent by user with admin permissions 
    // automatically assign the "accepted" status.
    if ($USER->IsAdmin() && $NEW_STATUS_ID == 1)
      $NEW_STATUS_ID = 2;
  }
}

// register function as event handler
AddEventHandler('form', 'onBeforeResultStatusChange', 'my_onBeforeResultStatusChange');

© «Bitrix24», 2001-2024