Answers.Body: <p>See: <a href="https://docs.craftcms.com/v3/dev/element-queries/user-queries.html#lastname" rel="nofollow noreferrer">https://docs.craftcms.com/v3/dev/element-queries/user-queries.html#lastname</a></p>
  
  <pre><code>{% set slug = 'first-last'|split('-') %}
  {% set firstNameSlug = slug[0] %}
  {% set lastNameSlug = slug[1] %}
  
  {% set user = craft.users.firstName(firstNameSlug).lastName(lastNameSlug).first %}
  </code></pre>
  
  <p>We only need to split once, so I spit the slug variable instead.</p>
  
  <p>You were passing <code>slug</code> to the first name method, but you would want to pass <code>firstNameSlug</code>.</p>
  
  <p>Alternately this can be written like this if you know the slug is correct:</p>
  
  <pre><code>{% set slug = 'first-last' %}
  {% set user = craft.users.slug(slug).first %}
  </code></pre>
  
  <p>But you said you don't want to do that so I'll assume you know what you are doing.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-13T16:46:26.450Z
Answers.LastActivityDate: 2020-03-13T16:46:26.450Z
Answers.UserDisplayName: Clark Nelson
Body: <p>I don't want to ustilise the username or the ID of a user to get their profile info so I am using their first and last name. So far I can fetch the user based on first name:</p>
  
  <pre><code>{% set slug = 'first-last' %}
  {% set firstNameSlug = slug|split('-')[0] %}
  {% set lastNameSlug = slug|split('-')[1] %}
  
  {% set user = craft.users.firstName(slug).first %}
  </code></pre>
  
  <p>How do I build on this code to fetch using the first name AND last name?</p>
  
Tags: <user-profile>
Title: Displaying Craft User Profile based on First and Last Name
ThreadText: # Displaying Craft User Profile based on First and Last Name
  
  (Asked by: username_0 on 2020-03-13)
  
  I don't want to ustilise the username or the ID of a user to get their profile info so I am using their first and last name. So far I can fetch the user based on first name:
  
  ```
  {% set slug = 'first-last' %}
  {% set firstNameSlug = slug|split('-')[0] %}
  {% set lastNameSlug = slug|split('-')[1] %}
  
  {% set user = craft.users.firstName(slug).first %}
  
  ```
  
  How do I build on this code to fetch using the first name AND last name?
  
  **Tags:** user-profile
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-03-13. Score: 2 | Accepted answer
  
  See: <https://docs.craftcms.com/v3/dev/element-queries/user-queries.html#lastname>
  
  ```
  {% set slug = 'first-last'|split('-') %}
  {% set firstNameSlug = slug[0] %}
  {% set lastNameSlug = slug[1] %}
  
  {% set user = craft.users.firstName(firstNameSlug).lastName(lastNameSlug).first %}
  
  ```
  
  We only need to split once, so I spit the slug variable instead.
  
  You were passing `slug` to the first name method, but you would want to pass `firstNameSlug`.
  
  Alternately this can be written like this if you know the slug is correct:
  
  ```
  {% set slug = 'first-last' %}
  {% set user = craft.users.slug(slug).first %}
  
  ```
  
  But you said you don't want to do that so I'll assume you know what you are doing.
  
  
  ---
  
  