Answers.Body: <p>You’d need to query for all Matrix Blocks the user is related to using a Matrix Block ElementCriteriaModel. Unfortunatelly this is not possible from the template level by default, you need to either install the plugin <a href="https://github.com/low/lowblocks" rel="nofollow">Low Blocks</a>, or write some some lines of PHP in a custom plugin.</p>
  
  <p>Here’s how you would have to set the params for the Low Blocks function:</p>
  
  <pre><code>{% set userId = craft.request.lastSegment %}
  {% set user = craft.users.id(userId).first() %}
  
  {% if not user %}
      {% exit 404 %}
  {% endif %}
  
  {% set matrixField = craft.fields.getFieldByHandle('commissionmembers') %}
  
  {% set blocks = craft.lowblocks.blocks.fieldId(matrixField.id).type('members').relatedTo({
      targetElement: userId,
      field: 'member',
  }) %}
  
  {% for block in blocks %}
      {% set commission = block.getOwner() %}
  
      {{ commission.title }}
      {{ block.function }}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-29T21:44:00.197Z
Answers.Text: Hey Carl, thank you so much for your help, it's working perfectly. However there was one thing I had to let out, and that is in the relatedTo, field: 'member'. With only the targetElement: userId it works perfectly.
Answers.UserDisplayName: John Stevens
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-29T14:01:38.377Z
Answers.LastActivityDate: 2016-09-29T14:01:38.377Z
Answers.UserDisplayName: carlcs
Body: <p>I have a commissions section in where we have a matrix field where we add the user (from craft.users) and the function of the user.</p>
  
  <p>A user can be in more that one commissions.</p>
  
  <p>On the user profile page, we want to show besides some personal information, all the commissions in which he is active.</p>
  
  <p>For a single relation field (user type field), we have no problem, but I can't get it working with this matrix field.</p>
  
  <p>Matrix field info:</p>
  
  <p>Section: <code>commissionmembers</code><br>
  Blocktype: <code>members</code><br> 
  Fields: <code>member</code> (fieldtype users)<br>
          <code>function</code> (plain text)</p>
  
  <p>This is a working example with a Users field</p>
  
  <pre><code>    {% for user in craft.users.id( craft.request.lastSegment ).limit(1) %}
      {% set commissions = craft.entries.section('commissions').relatedTo(user) %}
          {% for commission in commissions %}
              {{ commission.title }}
          {% endfor %}
      {% endfor %}
  </code></pre>
  
  <p>Hope you can point me in the right direction how to get it working with the matrix field</p>
  
Tags: <templating><matrix><users><fieldtypes><relatedto>
Title: Show on user profile page the commissions he is connected to
ThreadText: # Show on user profile page the commissions he is connected to
  
  (Asked by: username_0 on 2016-09-29)
  
  I have a commissions section in where we have a matrix field where we add the user (from craft.users) and the function of the user.
  
  A user can be in more that one commissions.
  
  On the user profile page, we want to show besides some personal information, all the commissions in which he is active.
  
  For a single relation field (user type field), we have no problem, but I can't get it working with this matrix field.
  
  Matrix field info:
  
  Section: `commissionmembers`  
  Blocktype: `members`  
  Fields: `member` (fieldtype users)  
  `function` (plain text)
  
  This is a working example with a Users field
  
  ```
      {% for user in craft.users.id( craft.request.lastSegment ).limit(1) %}
      {% set commissions = craft.entries.section('commissions').relatedTo(user) %}
          {% for commission in commissions %}
              {{ commission.title }}
          {% endfor %}
      {% endfor %}
  
  ```
  
  Hope you can point me in the right direction how to get it working with the matrix field
  
  **Tags:** templating, matrix, users, fieldtypes, relatedto
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-09-29. Score: 2 | Accepted answer
  
  You’d need to query for all Matrix Blocks the user is related to using a Matrix Block ElementCriteriaModel. Unfortunatelly this is not possible from the template level by default, you need to either install the plugin [Low Blocks](https://github.com/low/lowblocks), or write some some lines of PHP in a custom plugin.
  
  Here’s how you would have to set the params for the Low Blocks function:
  
  ```
  {% set userId = craft.request.lastSegment %}
  {% set user = craft.users.id(userId).first() %}
  
  {% if not user %}
      {% exit 404 %}
  {% endif %}
  
  {% set matrixField = craft.fields.getFieldByHandle('commissionmembers') %}
  
  {% set blocks = craft.lowblocks.blocks.fieldId(matrixField.id).type('members').relatedTo({
      targetElement: userId,
      field: 'member',
  }) %}
  
  {% for block in blocks %}
      {% set commission = block.getOwner() %}
  
      {{ commission.title }}
      {{ block.function }}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Hey Carl, thank you so much for your help, it's working perfectly. However there was one thing I had to let out, and that is in the relatedTo, field: 'member'. With only the targetElement: userId it works perfectly.  
  
  ---
  
  