Answers.Body: <p>Although the craft.users tag let you find users who have firstName or lastName matching whatever, I wouldn't try to match just against that, as you could end up having users with the same sames.</p>
  
  <p>I would include the id of the user in the URL, so you would have something like example.com/user/1-first-last</p>
  
  <p>Then you can lookup the profile by doing this:</p>
  
  <ol>
  <li>Add a <a href="http://buildwithcraft.com/docs/routing#dynamic-routes" rel="nofollow">dynamic route</a> that matches for example profile/(number)-*</li>
  <li><p>Graf the profile with something like this:</p>
  
  <pre><code>{# 
      - Use matches variable from dynamic route
      - matches.number will give you the expected id if you only have 
        one number segment in your dynamic route
  #}
  {% set userId = matches.number %}
  {# Find user #}
  {% if userId is defined %}
      {% set profile = craft.users.id(userId) | first %}
          {{ profile.name }}&lt;br/&gt;
          {{ profile.username }}&lt;br/&gt;
          {{ profile.email }}&lt;br/&gt;
          {{ profile.id }}&lt;br/&gt;
  {% endif %}
  </code></pre></li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-06T08:05:30.550Z
Answers.Text: I accepted yours now.
Answers.UserDisplayName: Marcus Scheller
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-16T14:53:40.413Z
Answers.Text: “as you could end up having users with the same sames”
  
  That’d definitely be an issue. Going with the id beforehand might be a good way to go. Thank you.
Answers.UserDisplayName: Marcus Scheller
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-17T10:50:52.883Z
Answers.Text: Good. In general, you want some kind of information that is sure to be unique to look up the user, like the id, username or e-mail.
Answers.UserDisplayName: Fred Carlsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-20T19:00:55.217Z
Answers.Text: @MarcusScheller Could you mark one of the answers as the accepted one?
Answers.UserDisplayName: Fred Carlsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-22T21:26:50.373Z
Answers.Text: We went with the username (identical names being an issue) so practically I haven’t further looked into any of the above.
Answers.UserDisplayName: Marcus Scheller
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-16T14:47:57.287Z
Answers.LastActivityDate: 2014-09-16T16:17:13.733Z
Answers.LastEditDate: 2014-09-16T16:17:13.733Z
Answers.UserDisplayName: Fred Carlsen
Answers.Body: <p>Marcus, I think you can use <em>anything</em> as an url for a user's page. In your case, I'd make a <a href="http://buildwithcraft.com/docs/routing#dynamic-routes" rel="nofollow">dynamic route</a> like:</p>
  
  <pre><code>user/*
  </code></pre>
  
  <p>and assign it a template, for instance:</p>
  
  <pre><code>user/_entry
  </code></pre>
  
  <p>Within that template, all you'd have to do is lookup the user by the match found in the url. The variable <em>matches</em> contains the first-last part (the * part of your route). With that, the user should be easy to find:</p>
  
  <pre><code>{% set names = matches[1] | split('-') %}
  {% set user = craft.users.firstName(names[0]).lastName(names[1]).first() %}
  
  {% if user %}
      // Do with it what you want
  {% endif %}
  </code></pre>
  
  <p>You'd have to be careful, however, that no two identical first- and last name combinations exists. The advantage of using the username is that it's always unique.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-16T14:56:38.487Z
Answers.Text: Thanks Paul.
  
  “two identical first- and last name combinations” -- True, so i might look into Fred’s suggestion using a combination of id and full name. Username would still be the fallback but just not preferred. At least i would not like that.
Answers.UserDisplayName: Marcus Scheller
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-16T14:30:54.137Z
Answers.LastActivityDate: 2014-09-16T14:30:54.137Z
Answers.UserDisplayName: Paul
Body: <p>I like to have the user’s full name in their profile page-url rather than the username in case they don’t want their username associated with their full name. In my case they don’t get to set the username at the sign up point but might been asked for a username by the person signing them up.</p>
  
  <p>So, how do i use the user’s full name as an identifier in the url of their profile page?</p>
  
  <p>Like so: <code>example.com/user/first-last</code></p>
  
  <p>Is that even possible?</p>
  
Tags: <url><user-profile>
Title: Using a user’s full name in the URL
ThreadText: # Using a user’s full name in the URL
  
  (Asked by: username_0 on 2014-09-16)
  
  I like to have the user’s full name in their profile page-url rather than the username in case they don’t want their username associated with their full name. In my case they don’t get to set the username at the sign up point but might been asked for a username by the person signing them up.
  
  So, how do i use the user’s full name as an identifier in the url of their profile page?
  
  Like so: `example.com/user/first-last`
  
  Is that even possible?
  
  **Tags:** url, user-profile
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-09-16. Score: 2 | Accepted answer
  
  Although the craft.users tag let you find users who have firstName or lastName matching whatever, I wouldn't try to match just against that, as you could end up having users with the same sames.
  
  I would include the id of the user in the URL, so you would have something like example.com/user/1-first-last
  
  Then you can lookup the profile by doing this:
  
  1. Add a [dynamic route](http://buildwithcraft.com/docs/routing#dynamic-routes) that matches for example profile/(number)-\*
  2. Graf the profile with something like this:
  
     ```
     {# 
         - Use matches variable from dynamic route
         - matches.number will give you the expected id if you only have 
           one number segment in your dynamic route
     #}
     {% set userId = matches.number %}
     {# Find user #}
     {% if userId is defined %}
         {% set profile = craft.users.id(userId) | first %}
             {{ profile.name }}<br/>
             {{ profile.username }}<br/>
             {{ profile.email }}<br/>
             {{ profile.id }}<br/>
     {% endif %}
  
     ```
  
  > **Comments:**
  > **username_0**: “as you could end up having users with the same sames”  That’d definitely be an issue. Going with the id beforehand might be a good way to go. Thank you.  
  > **username_1**: Good. In general, you want some kind of information that is sure to be unique to look up the user, like the id, username or e-mail.  
  > **username_1**: @username_0 Could you mark one of the answers as the accepted one?  
  > **username_0**: We went with the username (identical names being an issue) so practically I haven’t further looked into any of the above.  
  > **username_0**: I accepted yours now.  
  
  ---
  
  ### Answer by username_2 on 2014-09-16. Score: 4
  
  username_0, I think you can use *anything* as an url for a user's page. In your case, I'd make a [dynamic route](http://buildwithcraft.com/docs/routing#dynamic-routes) like:
  
  ```
  user/*
  
  ```
  
  and assign it a template, for instance:
  
  ```
  user/_entry
  
  ```
  
  Within that template, all you'd have to do is lookup the user by the match found in the url. The variable *matches* contains the first-last part (the \* part of your route). With that, the user should be easy to find:
  
  ```
  {% set names = matches[1] | split('-') %}
  {% set user = craft.users.firstName(names[0]).lastName(names[1]).first() %}
  
  {% if user %}
      // Do with it what you want
  {% endif %}
  
  ```
  
  You'd have to be careful, however, that no two identical first- and last name combinations exists. The advantage of using the username is that it's always unique.
  
  > **Comments:**
  > **username_0**: Thanks username_2.  “two identical first- and last name combinations” -- True, so i might look into username_1’s suggestion using a combination of id and full name. Username would still be the fallback but just not preferred. At least i would not like that.  
  
  ---
  
  