A
A
Andrey Bely2020-11-25 15:58:42
1C-Bitrix
Andrey Bely, 2020-11-25 15:58:42

Why are discounts assigned to a certain group of users not available to users who got into this group through the Bitrix API?

Good evening!
Through the admin panel, I assign the “Professionals Club” group to the user.
5fbe4d22ce52b382619471.png

I see discounts:
5fbe53693e730956422000.png

If I add via the API:

$dbGroup = \Bitrix\Main\UserGroupTable::getList(
                array(
                'filter' => array("USER_ID" => $USER->GetID(), "GROUP_ID" => 8)
                )
            );
            $arGroups = $dbGroup->FetchAll();

            if (empty($arGroups) && $arGroups[0]["GROUP_ID"] !== 8) {
                \Bitrix\Main\UserGroupTable::add(
                 array(
                     'USER_ID' => $USER->GetID(),
                     'GROUP_ID' => 8,
                 )
                );


I don't see anything, even after reloading the page. If I click on the "Exit" button, and then log back in, discounts appear.
Logging out and re-authorizing is inconvenient, it is necessary that discounts appear immediately after assigning a group to a user.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-11-25
@just_guy95

If I click on the "Exit" button, and then log back in, discounts appear.

This is the answer. Roughly speaking, the user's groups are always those in which he was at the entrance (by the way, this is done almost everywhere where there are groups).
In your case, the easiest way is to re-login the user after adding it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question