title: Yii 2 Menu Display List Depending on User
body: <p>How do I configure or customize my Menu where in, for example, if I am an <strong>admin</strong> user, I can see everything on my navigation bar, like, in my case, the <strong>Users</strong> (list of Users where I can create, update, or delete one), <strong>Stores</strong> (just like Users, this is where I can configure a specific store), <strong>Transactions</strong> and then the <strong>Logout</strong> button. But when an <strong>ordinary user/staff</strong> logs in, the only thing he/she will see is the <strong>Transactions</strong> menu and a <strong>Logout</strong> button as well.</p>
  
  <p>Please help.</p>
  
  <p><strong>Edit</strong>:
  Here is my menu rendering code:</p>
  
  <pre><code>&lt;?php
      echo Menu::widget([
          'options' =&gt; ['id' =&gt; "nav-mobile", 'class' =&gt; 'right side-nav'],
          'items' =&gt; [
            ['label' =&gt; 'Home', 'url' =&gt; ['/site/index']],
            ['label' =&gt; 'About', 'url' =&gt; ['/site/about']],
            ['label' =&gt; 'Contact', 'url' =&gt; ['/site/contact']],
            Yii::$app-&gt;user-&gt;isGuest ?
                ['label' =&gt; 'Login', 'url' =&gt; ['/site/login']] :
                ['label' =&gt; 'Logout (' . Yii::$app-&gt;user-&gt;identity-&gt;username . ')',
                    'url' =&gt; ['/site/logout'],
                    'linkOptions' =&gt; ['data-method' =&gt; 'post']
                ],
        ],
      ]);
  ?&gt;
  </code></pre>