<p>Without knowing how your templates look, I can only give you a basic example:</p>

<pre><code>{% set team    = craft.users.username(craft.request.lastSegment) %}
{% set entries = craft.entries.section('schedules').relatedTo(team) %}
</code></pre>

<p>This should give you all entries in the <code>schedules</code> channel which have a relation to the <code>team</code> username.</p>

CC BY-SA 3.0
2014-06-18T18:17:32.030Z
2014-06-18T18:17:32.030Z
Victor
<p>I have a sports site I'm building where each team is set up as a user within a 'team' member group.  I have a channel called 'Schedule' that has only 2 fields; a user field to relate the schedule to a team and then a table for the list of games.</p>

<p>On the front-end if I have a profile page for each team (ie: <code>http://www.example.com/{username}</code>).  I'm having trouble outputting the correct schedule based on the username in the URL?</p>

CC BY-SA 3.0
2014-06-18T18:06:59.693Z
Are you able to pull a User from the username? Have you set up this page in your Routes?
Bryan Redeagle
CC BY-SA 3.0
2014-06-18T18:10:43.060Z
Let's have a look at your templates too! That would help us help you :)
Mark Busnelli Jr
<users>
Using relatedTo with 'Users' field
# Using relatedTo with 'Users' field

(Asked by: username_0 on 2014-06-18)

I have a sports site I'm building where each team is set up as a user within a 'team' member group. I have a channel called 'Schedule' that has only 2 fields; a user field to relate the schedule to a team and then a table for the list of games.

On the front-end if I have a profile page for each team (ie: `http://www.example.com/{username}`). I'm having trouble outputting the correct schedule based on the username in the URL?

**Tags:** users

> **Comments:**
> **username_1**: Are you able to pull a User from the username? Have you set up this page in your Routes?  
> **username_2**: Let's have a look at your templates too! That would help us help you :)  

---

## 1 answers

### Answer by username_3 on 2014-06-18. Score: 1

Without knowing how your templates look, I can only give you a basic example:
{% set team    = craft.users.username(craft.request.lastSegment) %}
{% set entries = craft.entries.section('schedules').relatedTo(team) %}

This should give you all entries in the schedules channel which have a relation to the team username.


---

