I
I
IGrch2018-02-16 10:27:07
1C-Bitrix
IGrch, 2018-02-16 10:27:07

How to set a condition for displaying personal user account data?

It is necessary to display data of 2 types on the page, depending on what kind of user opened the page:
1) if a regular user, then the data of this user (accounting Bitrix) is displayed
2) if the user is from the ICS list (by ID), then the data of all users is displayed (bitrix account)
I display the data of one user by ID:

<?
global $USER;
$filter = Array('ID' => '28096');
$rsUsers = CUser::GetList(($by="PERSONAL_STATE"), ($order="desc"), $filter);
while($rsUsers->NavNext(true, "f_"));
echo $f_PERSONAL_NOTES;
echo $f_WORK_STATE;
endwhile;
?>

How to write an if/else construct so that: if id = 1, 2, 3 ... , then display the data as in the code example (several users)
otherwise, display the data of the logged in user (in my example, it just changes to GetID)
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Epifanov, 2018-02-16
@kacheleff

You can pass several IDs to the CUser::GetList filter, for this you need to separate them with a symbol |
. You can do it, for example, like this:

$arId = array(1,2,3);
$filter = Array('ID' =>  implode('|', $arId));
$rsUsers = CUser::GetList(($by="PERSONAL_STATE"), ($order="desc"), $filter);

documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question