I try to filter users by several parameters:

There are three checkbox properties that each user has affixed. Bitrix filter works like this: GROUP1 AND GROUP2 are ticked, it shows the users who have the tick at the same time and that and this group. If I need to display the Users GROUP1 OR GROUP2 then it stops showing.

$test_value = Array( array( "LOGIC" => "OR", "UF_TMC1" => $filter1["UF_TMC1"], "UF_TMC2" => $filter2["UF_TMC2"], "UF_TMC3" => $filter3["UF_TMC3"], ), "GROUPS_ID" => "7", ); $arSelect = array('SELECT' => array('UF_SURNAME', 'UF_NAME', 'UF_MIDNAME', 'GROUP_ID', 'UF_TMC1', 'UF_TMC2', 'UF_TMC3')); $rsUsers = CUser::GetList(($by="ID"), ($order = "asc"), $test_value, $arSelect); while($reg = $rsUsers->Fetch()){ $arUses = $reg; $mailUser11[] = $arUses["EMAIL"]; } 
  • Well, did you read the manual - the ability to search through LOGIC => OR exists for CUser::GetList ? - u_mulder
  • @u_mulder is not much written in manuals, so you have to do everything. Tell me how to proceed. - Evgeny Pivovarov

1 answer 1

Use the D7 API:

 $rsUsers = \Bitrix\Main\UserTable::getList([ 'select' => [ 'UF_NAME', 'UF_MIDNAME', 'UF_SURNAME', ], 'filter' => [ [ 'LOGIC' => 'OR', 'UF_TMC1' => $filter1['UF_TMC1'], 'UF_TMC2' => $filter1['UF_TMC2'], 'UF_TMC3' => $filter1['UF_TMC3'], ], 'GROUPS_ID' => 7, ], 'order' => ['ID' => 'asc'], ]); while ($reg = $rsUsers->fetch()) { // .. } 
  • why not the original bitrix style stick array ()? - Eugene Nagornichyh
  • Maybe still on php5.3 to program? By the way, shouldn't the conditions for OR be separate arrays? - u_mulder
  • Because starting with php 4 it has become unnecessary, besides, it saves a lot of time when writing large volume code and increases the readability of the code - Bolverkr Eldjarnson
  • The conditions for an OR may or may not be arrays, depending on the specific task. In most cases, declaring separate arrays is not necessary - Bolverkr Eldjarnson