<p>If I'm following you, you've got restaurants set up as user accounts in Craft and you've got a category field assigned to the Users field layout and you're trying to access those categories.</p>

<p>If so, it's as simple as it is in the docs: <a href="https://craftcms.com/docs/categories-fields#templating" rel="nofollow noreferrer">https://craftcms.com/docs/categories-fields#templating</a></p>

<pre><code>{% set categories = restaurant.categoryFieldHandle %}
</code></pre>

<p>That will assign all of the categories to a variable named <code>category</code>.  If you know there will only ever be one, then you can use:</p>

<pre><code>{% set categories = restaurant.categoryFieldHandle.first() %}
</code></pre>

CC BY-SA 3.0
2017-03-26T22:37:16.747Z
2017-03-26T22:37:16.747Z
Brad Bell
<p>How can I display category name on template used in user->group.</p>

<pre><code>{% for restaurant in craft.users.username(userId) %}
    {{ restaurant.name }}
    {{ restaurant.addressLine1 }} {{ restaurant.addressLine2 }}
    --
    // display the category name which has been added in restaurant-&gt;Group under Users
    --
{% endfor %}
</code></pre>

CC BY-SA 3.0
2017-05-09T19:59:31.527Z
Hi Mohit, would you mind following up on this question and letting us know if Brad's answer solved it or if you found your own way? You can add and accept your own answer here if you want!
Matt Stein
<templating><users><categories>
Fetch category name
# Fetch category name

(Asked by: username_0 on 2017-03-25)

How can I display category name on template used in user->group.
{% for restaurant in craft.users.username(userId) %}
    {{ restaurant.name }}
    {{ restaurant.addressLine1 }} {{ restaurant.addressLine2 }}
    --
    // display the category name which has been added in restaurant->Group under Users
    --
{% endfor %}

**Tags:** templating, users, categories
> **Comments:**
> **username_1**: Hi Mohit, would you mind following up on this question and letting us know if Brad's answer solved it or if you found your own way? You can add and accept your own answer here if you want!  

---

## 1 answers

### Answer by username_2 on 2017-03-26. Score: 1

If I'm following you, you've got restaurants set up as user accounts in Craft and you've got a category field assigned to the Users field layout and you're trying to access those categories.
If so, it's as simple as it is in the docs: https://craftcms.com/docs/categories-fields#templating
{% set categories = restaurant.categoryFieldHandle %}

That will assign all of the categories to a variable named category.  If you know there will only ever be one, then you can use:
{% set categories = restaurant.categoryFieldHandle.first() %}


---

