Answers.Body: <p><code>.first()</code> is going to be required... I updated the answer in the original question, but here it is for posterity, too:</p>
  
  <pre><code>{% set notWorkingUserId = craft.request.getSegment(2) %}
  {% set notWorkingUser = craft.users.id(notWorkingUserId).first() %}
  </code></pre>
  
  <p>Then you can access the properties of that user because it's a proper <a href="http://buildwithcraft.com/classreference/models/UserModel" rel="nofollow">UserModel</a> now:</p>
  
  <pre><code>notWorkingUser.email
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-20T21:34:00.600Z
Answers.Text: Ah brilliant thanks, good to know it's not me going insane. Could you provide a link to the docs as to *why* `.first()` is required please? As to my mind it isn't an array — right? Or is it?
Answers.UserDisplayName: Rob
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-20T22:26:32.710Z
Answers.Text: There's a good explanation on it here: http://craftcms.stackexchange.com/a/271/57
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-20T20:03:14.463Z
Answers.LastActivityDate: 2015-07-20T20:03:14.463Z
Answers.UserDisplayName: Brad Bell
Body: <p>I've been referring to <a href="https://craftcms.stackexchange.com/questions/1308/user-profile-public-page">this question</a> (can't comment as I don't have enough cred) — The most popular answer works, but I can't for the life of me figure out why Brad's version doesn't. When I try I get the following error:</p>
  
  <pre><code>Object of class Craft\ElementCriteriaModel could not be converted to string
  
  {# Not Working (Brad's version) #}
  {% set notWorkingUserId = craft.request.getSegment(2) %}
  {% set notWorkingUser = craft.users.id(notWorkingUserId) %}
  
  {# Working #}
  {% set workingUser = craft.users.username( craft.request.segment(2) ).first() %}
  
  
  {% block content %}
  
      &lt;h1&gt;Not Working: {{ notWorkingUser.email }}&lt;/h1&gt;
      &lt;h1&gt;Working: {{ workingUser.email }}&lt;/h1&gt;
  
      {{notWorkingUser}} {# Throws an error #}
      {{workingUser}}
  
  {% endblock %}
  </code></pre>
  
  <p>I'm using the dynamic url routing mentioned in the most popular example, with the username. I also tried:</p>
  
  <pre><code>craft.users.username(notWorkingUserId)
  </code></pre>
  
  <p>Which throws the same error.</p>
  
  <p>Now as far as I understand it (I've only been working with Craft for a short period), .first() is only required when it's an array. But Brad's version is passing the actual ID so shouldn't be required?</p>
  
  <p>Can anyone explain this in simple terms? Craft is great, but for beginners it can get a bit confusing.</p>
  
Tags: <url><routing><error><request>
Title: Public profile page: requesting user ID with dynamic url routing
ThreadText: # Public profile page: requesting user ID with dynamic url routing
  
  (Asked by: username_0 on 2015-07-20)
  
  I've been referring to [this question](https://craftcms.stackexchange.com/questions/1308/user-profile-public-page) (can't comment as I don't have enough cred) — The most popular answer works, but I can't for the life of me figure out why username_1's version doesn't. When I try I get the following error:
  
  ```
  Object of class Craft\ElementCriteriaModel could not be converted to string
  
  {# Not Working (username_1's version) #}
  {% set notWorkingUserId = craft.request.getSegment(2) %}
  {% set notWorkingUser = craft.users.id(notWorkingUserId) %}
  
  {# Working #}
  {% set workingUser = craft.users.username( craft.request.segment(2) ).first() %}
  
  {% block content %}
  
      <h1>Not Working: {{ notWorkingUser.email }}</h1>
      <h1>Working: {{ workingUser.email }}</h1>
  
      {{notWorkingUser}} {# Throws an error #}
      {{workingUser}}
  
  {% endblock %}
  
  ```
  
  I'm using the dynamic url routing mentioned in the most popular example, with the username. I also tried:
  
  ```
  craft.users.username(notWorkingUserId)
  
  ```
  
  Which throws the same error.
  
  Now as far as I understand it (I've only been working with Craft for a short period), .first() is only required when it's an array. But username_1's version is passing the actual ID so shouldn't be required?
  
  Can anyone explain this in simple terms? Craft is great, but for beginners it can get a bit confusing.
  
  **Tags:** url, routing, error, request
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-07-20. Score: 1 | Accepted answer
  
  `.first()` is going to be required... I updated the answer in the original question, but here it is for posterity, too:
  
  ```
  {% set notWorkingUserId = craft.request.getSegment(2) %}
  {% set notWorkingUser = craft.users.id(notWorkingUserId).first() %}
  
  ```
  
  Then you can access the properties of that user because it's a proper [UserModel](http://buildwithcraft.com/classreference/models/UserModel) now:
  
  ```
  notWorkingUser.email
  
  ```
  
  > **Comments:**
  > **username_0**: Ah brilliant thanks, good to know it's not me going insane. Could you provide a link to the docs as to *why* `.first()` is required please? As to my mind it isn't an array — right? Or is it?  
  > **username_1**: There's a good explanation on it here: http://craftcms.stackexchange.com/a/271/57  
  
  ---
  
  