Y
Y
YakutD2019-09-04 17:57:17
1C-Bitrix
YakutD, 2019-09-04 17:57:17

Why are all users included in the sample?

Hello. I want to make a selection of users who are NOT included in certain groups.
Here is my code:

$users = CUser::GetList(['LAST_NAME'=>'asc'],'asc',['!GROUPS_ID'=>[29,35,30,279,34]]);

Further I do normal search through While and I deduce id of the received users.
In fact, I get a sample of ALL users.
I also tried to first get the IDs of users included in unnecessary groups, and filter by !ID=>[list of IDs of these users] but it didn’t help, the result is the same. What is wrong in my code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex-1917, 2019-09-04
@YakutD

There is a ready-made example in the comments to the off. documentation...
// First, select the user IDs that belong to the group for which you want to make an exception
// At the second step, using complex logic, we will negate the selected user IDs

$rsUsers = CUser::GetList($by = "", $order = "", array("ID" => "~".implode("& ~", $arUsers)));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question