Support Forum
Hi,
I have a custom group field (location = user) consisting of type of document and the url of the document.
This relates to students, a student can see his own documents.
I want the teacher to be able to see the documents as well.
To facilitate that, there is a custom field student_id - for the student it always contains his own user.ID, for the teacher the user.ID of the student he's watching. This field always contains the right value, I've doble-checked that.
For the student it's working properly, but the teacher doesn't see the student's documents.
This is my code (for documented interviews):
{% set counter = 0 %}
{{ user.student_id }}
[rwmb_meta id="user.document_group" object_id="{{ user.student_id }}"]
<div class="sub_container">
{% for clone in user.document_group %}
{% if 'Interview' in clone.type_of_document.value %}
{% set counter = counter +1 %}
<div class="sub_item">
<a href="{{ clone.document }}"><img class="alignnone size-full wp-image-328" src="https://<mydomain>/wp-content/uploads/sites/57/2024/07/pdf.jpg" alt="" width="128" height="159" /></a><br>
<a href="{{ clone.document }}">{{ clone.type_of_document.value }}</a>
</div>
{% endif %}
{% endfor %}
</div>
{% if counter == 0 %}
No Interviews yet
{% endif %}
(I just display the student_id to confirm the user id being watched.)
Pls help me to get the code working for the teacher as well.
Hello Eddy,
If you have the student ID, you can use the code below to get the student field (user meta).
{% set student_document = mb.rwmb_meta( 'document_group', { object_type: 'user' }, user.student_id ) %}
{% for clone in student_document %}
...
{% endfor %}
please update the field document_group
ID if it isn't correct. Following the documentation
https://docs.metabox.io/extensions/mb-user-meta/#getting-field-value
and the previous topic https://support.metabox.io/topic/how-to-get-field-value-in-the-settings-page/
Hi Peter,
Thanks, with your help I got it working.