E
E
Evgeny Osipov2020-05-06 19:42:13
1C-Bitrix
Evgeny Osipov, 2020-05-06 19:42:13

Why is the onAfterResultAdd event handler not working?

1C-Bitrix: Site Management 20.0.950
Forms were already in the solution from Aspro.

When submitting form ID 15, I try to change the UF_CLIENT user field, but it doesn't work.

I'm trying to just send myself a message when submitting the form, but nothing comes up.
The message itself comes from the form, but the onAfterResultAdd event doesn't fire.
Tell me what I'm doing wrong?

In init.php added:

<?
    AddEventHandler("form", "onAfterResultAdd", "wsAfterForm");
    function wsAfterForm($WEB_FORM_ID, $RESULT_ID) {
        if ($WEB_FORM_ID == 15) {
            mail("моя_почта", "Тест формы", "Тест формы");

            // global $USER;
            // $USER_ID = $USER->GetID();

            // $user = new CUser;
            // $fields = Array(
            //     "UF_CLIENT" => "1",
            // );
            // $user -> Update($USER_ID, $fields);

        }
    }
?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Osipov, 2020-05-07
@Medik18

User PetrPo in the comments helped to sort out the problem.
It was necessary to track the infoblock instead of the form.

G
Guliver99, 2021-05-27
@Guliver99

and in the box due to the fact that the forms are created on the left server, and the box on its own. a bolt was scored on these events

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question