Answers.Body: <p>Depends on whether the user field is on the product or a variant.</p>
  
  <p>If the custom field is on the product:</p>
  
  <pre><code>{% set products = craft.commerce.products.relatedTo({
      sourceElement: currentUser,
      field: 'userFieldName'
  }) %}
  </code></pre>
  
  <p>If the custom field is on the variant:</p>
  
  <pre><code>{% set variantCriteria = craft.commerce.variants.relatedTo({
      sourceElement: currentUser,
      field: 'userFieldName'
  }) %}
  
  {% set products = craft.commerce.products.hasVariant(variantCriteria) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-20T15:18:16.060Z
Answers.Text: The custom field is on the product. I should have added, that I previously attempted your first suggestion, but it didn't return any results.
Answers.UserDisplayName: JackO
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-20T15:09:03.453Z
Answers.LastActivityDate: 2017-02-20T15:09:03.453Z
Answers.UserDisplayName: Luke Holder
Body: <p>I have a custom field enabled on a product - it is a user field that associates a product with a user.</p>
  
  <p>What would the correct setup be to only display products that pertain to the currentUser - as this would match the custom user field?</p>
  
Tags: <plugin-craftcommerce><custom-field>
Title: Show products based on custom field
ThreadText: # Show products based on custom field
  
  (Asked by: username_0 on 2017-02-20)
  
  I have a custom field enabled on a product - it is a user field that associates a product with a user.
  
  What would the correct setup be to only display products that pertain to the currentUser - as this would match the custom user field?
  
  **Tags:** plugin-craftcommerce, custom-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-02-20. Score: 1
  
  Depends on whether the user field is on the product or a variant.
  
  If the custom field is on the product:
  
  ```
  {% set products = craft.commerce.products.relatedTo({
      sourceElement: currentUser,
      field: 'userFieldName'
  }) %}
  
  ```
  
  If the custom field is on the variant:
  
  ```
  {% set variantCriteria = craft.commerce.variants.relatedTo({
      sourceElement: currentUser,
      field: 'userFieldName'
  }) %}
  
  {% set products = craft.commerce.products.hasVariant(variantCriteria) %}
  
  ```
  
  > **Comments:**
  > **username_0**: The custom field is on the product. I should have added, that I previously attempted your first suggestion, but it didn't return any results.  
  
  ---
  
  