In Magento2, We have Access Control Lists (ACL) feature to restrict pages based on user access control. We might need to restrict some html div for specific users so in this case magento2 in we need to add access control condition in phtml file.
In this blog, We can see how we can add access control condition in .phtml file.
PHP
<?php if ($block->getAuthorization()->isAllowed('Magento_Backend::myaccount')) : ?>
<div> <?= $block->escapeHtml(__('This display to user who has my account access')) ?> </div>
<?php endif; ?>
We can see similar code in magento default.
I hope this blog is useful to add phtml file in admin access control in magento2. In case, I missed anything or need to add some more information, Don’t heisted to leave a comment in this blog, I’ll get back with some positive approach.
Keep loving ❤️ Keep inspiring 🤩 Keep liking 👍 No sharing 😂
1 Comment
Choose BWER for trusted weighbridge systems in Iraq, offering customized solutions to optimize your industrial operations and ensure precise weight measurement every time.