Answers.Body: <p>You need to use 'currentUser' to access the field. So;</p>
  
  <pre><code>{% for block in currentUser.myMatrix %}
    {{ block.myMatrixField1 }}
    {{ block.myMatrixField2 }}
  {% endfor %}
  </code></pre>
  
  <p>As for creating a new record in the matrix (I'm guessing you mean from the front end) then you need to create a form that submits the current matrix data alongside your new block data. This isn't super straight forward, but basically you need to create a <a href="https://docs.craftcms.com/v3/dev/examples/user-profile-form.html#simple-profile" rel="nofollow noreferrer">user profile form</a> that submits the current matrix data alongside the new data.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-19T06:00:12.613Z
Answers.Text: Very helpful.  Thank you!!
Answers.UserDisplayName: Erant
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-18T10:20:38.030Z
Answers.LastActivityDate: 2019-10-18T10:20:38.030Z
Answers.UserDisplayName: dmatthams
Body: <p>Using Craft 3.</p>
  
  <p>I created the following field:</p>
  
  <p><code>myMatrix</code> which has Field Type = matrix
  and is part of the group <code>myGroup</code></p>
  
  <p>This is composed of one block:</p>
  
  <p><code>myMatrixBlock</code>
  with 2 fields:</p>
  
  <p><code>myMatrixField1</code></p>
  
  <p><code>myMatrixField2</code></p>
  
  <p>I have assigned the myMatrix field to Users using the control panel (user settings >> fields).</p>
  
  <p>How do I</p>
  
  <ol>
  <li><p>Access the data in myMatrix from my twig template?  I'd like to get all the data in this matrix for the current user and loop through it and display data for each myMatrixField1 &amp; Field2.  I can't figure out how to retrieve <code>myMatrix</code> field.</p></li>
  <li><p>How do I create a new record in the <code>myMatrix</code> field? I'd like to create a new entry in the <code>myMatrix</code> field and store data for the current user in each of the fields. </p></li>
  </ol>
  
  <p>I've been searching at this for several hours now ... I feel this must be VERY easy but I can't seem to figure it out.  Also, if you have a link to documentation on functions/variables that are available for each object at the template level I'd be grateful.  I can't seem to find that in the docs either.</p>
  
  <p>Thank you!</p>
  
Tags: <matrix>
Title: Access Matrix field that is assigned to a user
ThreadText: # Access Matrix field that is assigned to a user
  
  (Asked by: username_0 on 2019-10-18)
  
  Using Craft 3.
  
  I created the following field:
  
  `myMatrix` which has Field Type = matrix
  and is part of the group `myGroup`
  
  This is composed of one block:
  
  `myMatrixBlock`
  with 2 fields:
  
  `myMatrixField1`
  
  `myMatrixField2`
  
  I have assigned the myMatrix field to Users using the control panel (user settings >> fields).
  
  How do I
  
  1. Access the data in myMatrix from my twig template? I'd like to get all the data in this matrix for the current user and loop through it and display data for each myMatrixField1 & Field2. I can't figure out how to retrieve `myMatrix` field.
  2. How do I create a new record in the `myMatrix` field? I'd like to create a new entry in the `myMatrix` field and store data for the current user in each of the fields.
  
  I've been searching at this for several hours now ... I feel this must be VERY easy but I can't seem to figure it out. Also, if you have a link to documentation on functions/variables that are available for each object at the template level I'd be grateful. I can't seem to find that in the docs either.
  
  Thank you!
  
  **Tags:** matrix
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-10-18. Score: 1 | Accepted answer
  
  You need to use 'currentUser' to access the field. So;
  
  ```
  {% for block in currentUser.myMatrix %}
    {{ block.myMatrixField1 }}
    {{ block.myMatrixField2 }}
  {% endfor %}
  
  ```
  
  As for creating a new record in the matrix (I'm guessing you mean from the front end) then you need to create a form that submits the current matrix data alongside your new block data. This isn't super straight forward, but basically you need to create a [user profile form](https://docs.craftcms.com/v3/dev/examples/user-profile-form.html#simple-profile) that submits the current matrix data alongside the new data.
  
  > **Comments:**
  > **username_0**: Very helpful.  Thank you!!  
  
  ---
  
  