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 😂

22 Comments

  1. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  2. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  3. OK, I gotta say, okjl44 caught my attention. Games are running smoothly and the overall experience is good so far! okjl44

  4. Straight to the point, I like it! go123casinologin does exactly what it says on the tin. Nice and speedy login process. Saves time, gets you playing faster. That’s a win in my book! Login at go123casinologin!

  5. Just browsing b999, the website loaded quick and it was a clean design aesthetic. Easy on the eyes. Going to give it another look later. See for yourself at b999

  6. **neurosharp official**

    Neuro Sharp is an advanced cognitive support formula designed to help you stay mentally sharp, focused, and confident throughout your day.

  7. **balmorex**

    balmorex is an exceptional solution for individuals who suffer from chronic joint pain and muscle aches.

Write A Comment