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 😂

20 Comments

  1. I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

  2. When it comes to roof installation in Lancaster, Roof Installation Pros stands out for quality and reliability. Their expert team works with all roof types, delivering strong, protective installations that add value. Highly rated for affordable, on-time, and professional roofing work.

  3. Need top-notch roof installation in Lancaster? Roof Installation Pros delivers professional services with a skilled team ready to handle all roof types. Their work is reliable, durable, and adds value to your home—trusted by many for timely and budget-friendly roofing solutions.

  4. When it comes to roof installation in Lancaster, Roof Installation Pros stands out for quality and reliability. Their expert team works with all roof types, delivering strong, protective installations that add value. Highly rated for affordable, on-time, and professional roofing work.

  5. Get reliable roof installation services in Lancaster with Roof Installation Pros. Whether it’s a new roof or a replacement, their experienced crew delivers quality craftsmanship that lasts. Known for fair pricing and dependable results that boost home value—your roof is in safe hands.

  6. Searching for trusted roof installation in Lancaster? Roof Installation Pros provides expert services across all roofing styles. Their experienced team guarantees strong, lasting installations that enhance your home’s protection and market value. Excellent service, always on time and within budget.

  7. 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?

  8. 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?

Write A Comment