Answer the question
In order to leave comments, you need to log in
Why is IsAuthorized not working?
Can you please tell me why IsAuthorized does not work in the infoblock, but everything is ok outside the infoblock?
I created an infoblock to allow only authorized users to download the file and posted the following code:
<?foreach($arResult["ITEMS"] as $arItem):?>
<div>
<?if(CUser::IsAuthorized()):?>
<ul>
<li><a href="<?=$arItem["PROPERTIES"]["ATT_FILE"]["VALUE"]?>">Скачать в PDF</a></li>
<li><a href="<?=$arItem["PROPERTIES"]["ATT_COMMENT"]["VALUE"]?>">Комментировать</a></li>
</ul>
<?else:?>
<ul>
<li>
<a>
<span>Скачать в PDF</span>
<span>Скачивание и Комментирование возможно только после регистрации.</span>
</a>
<li>
<a>
<span>Комментирование</span>
<span>Скачивание и Комментирование возможно только после регистрации.</span>
</a>
</li>
</ul>
<?endif;?>
</div>
<?endforeach;?>
Answer the question
In order to leave comments, you need to log in
Solution: disable caching.
The component template is cached and therefore shown equally to both authorized and unauthorized users.
To determine the authorization for the current user, you must use the global variable $USER
global $USER;
if ($USER->IsAuthorized()) echo "Вы авторизованы!";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question