<p>OK, so enabling the devMode helped point me in the right direction.  </p>

<p>First, I needed to change it to </p>

<pre><code>{% if currentUser and currentUser.isInGroup('advisors') %}
</code></pre>

<p>Otherwise I was getting an error message when nobody was logged in ("Impossible to invoke a method ("isInGroup") on a null variable").</p>

<p>Then I discovered that the user I was testing wasn't added to any groups!  I could have sworn I set up the user with a group assigned, but apparently not.  :(</p>

CC BY-SA 3.0
2017-01-10T02:50:27.967Z
2017-01-10T02:50:27.967Z
Todd
<p>I'm trying to show a menu based on what group a user is in once they have logged in.  However, I'm not having any success.  Here is an example (for one of the groups) of what I have in my <code>_base.html</code> file, which I'm extending in my other pages:</p>

<pre><code>{% if currentUser.isInGroup('advisors') %}
    &lt;div class="secondary-navigation"&gt;
        &lt;div class="row"&gt;
            &lt;div class="small-1 columns group"&gt;
                &lt;h2&gt;Advisors&lt;/h2&gt;
            &lt;/div&gt;
            &lt;div class="small-11 columns navigation"&gt;
                &lt;ul&gt;
                    &lt;li&gt;&lt;a href=""&gt;Advisors Home&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href=""&gt;Education&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href=""&gt;Blog&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href=""&gt;Events&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href=""&gt;Nav 5&lt;/a&gt;&lt;/li&gt;
                &lt;/ul&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
{% endif %}
</code></pre>

<p>Any suggestions would be most welcome!</p>

CC BY-SA 3.0
2017-01-09T20:31:03.467Z
That looks reasonable to me. What is it doing wrong?
Marion Newlevant
CC BY-SA 3.0
2017-01-09T21:48:37.183Z
It's not displaying the menu when I log in as a "client" user (or one of the others that I've got set up.
Todd
CC BY-SA 3.0
2017-01-09T22:11:35.300Z
So you log in as a client, which is in the `advisors` group, but that piece of the nav doesn't get displayed? Do you have `devMode` on?
Marion Newlevant
CC BY-SA 3.0
2017-01-09T22:18:57.960Z
No.  I'm a Craft noob, and wasn't aware of that.  I will enable it and do some more testing.  Thanks!
Todd
<user-groups>
Trying to Add a Specific Menu Depending on User Group
# Trying to Add a Specific Menu Depending on User Group

(Asked by: username_0 on 2017-01-09)

I'm trying to show a menu based on what group a user is in once they have logged in.  However, I'm not having any success.  Here is an example (for one of the groups) of what I have in my _base.html file, which I'm extending in my other pages:
{% if currentUser.isInGroup('advisors') %}
    
        
            
                Advisors
            
            
                
                    Advisors Home
                    Education
                    Blog
                    Events
                    Nav 5
                
            
        
    
{% endif %}

Any suggestions would be most welcome!

**Tags:** user-groups
> **Comments:**
> **username_1**: That looks reasonable to me. What is it doing wrong?  
> **username_0**: It's not displaying the menu when I log in as a "client" user (or one of the others that I've got set up.  
> **username_1**: So you log in as a client, which is in the `advisors` group, but that piece of the nav doesn't get displayed? Do you have `devMode` on?  
> **username_0**: No.  I'm a Craft noob, and wasn't aware of that.  I will enable it and do some more testing.  Thanks!  

---

## 1 answers

### Answer by username_0 on 2017-01-10. Score: 1 | Accepted answer

OK, so enabling the devMode helped point me in the right direction.  
First, I needed to change it to 
{% if currentUser and currentUser.isInGroup('advisors') %}

Otherwise I was getting an error message when nobody was logged in ("Impossible to invoke a method ("isInGroup") on a null variable").
Then I discovered that the user I was testing wasn't added to any groups!  I could have sworn I set up the user with a group assigned, but apparently not.  :(


---

