Answer the question
In order to leave comments, you need to log in
YII2 how to make frontend button visible to admin only?
I need to hide some elements in the frontend if the admin is not logged into the admin. How can you tell in the frontend if a user is logged in to the backend? Who knows?
<a class="btn btn-primary" href="/backend/web/shop/product/update?id=<?=$product->id;?>" target="blank">РЕДАКТИРОВАТЬ</a>
Answer the question
In order to leave comments, you need to log in
<?php if(Yii::$app->user->identity && Yii::$app->user->identity->getIsAdmin()):?>
<a class="btn btn-primary" href="/backend/web/shop/product/update?id=<?=$product->id;?>" target="blank">РЕДАКТИРОВАТЬ</a>
<?php endif; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question