Possibility to change some information from a child by a parent within the same form

By: Jaap Bastiaansen | Asked: 07/29/2024
ForumsCategory: Code SnippetsPossibility to change some information from a child by a parent within the same form
Jaap Bastiaansen asked 5 months ago
I am making a register for a group of people where everybody has their own login and dashboard.
In this register will also be some children where the parents want to have the right to change their data. To put it into an example:
Within the same form.
Parent (ID 22) wants to change some data from child 1 (ID 59)
Parent (ID 22) changes Field ID 93 (first name) which should change Field ID 9 from Child 1 (ID 59) The same for Field ID 91 and Field ID 92 which should change the field IDs 22 and 23 of the Child (User ID 59). More perfectly I would find a solution where, within the same form, this could be done for multiple children. This situation would count for different families. The parents can't be administrators. 

The main cause is, that the register can be downloaded to a CSV and every single entry (child and parent) will have its own line in the file at the same row (first name, last name, etc.). If there is a solution using multiple forms, that would also be fine, as long as one CSV with all the most up-to-date data can be downloaded.    I hope this is possible via an PHP code snippet. I tried to write it with ChatGPT, but that didn't work out so far. 
2 Answers
Victor Font answered 5 months ago
Use a single form with a repeater field for the children. Repeater fields are examples of embedded forms. You create a view to display your data and you can export your view.
Jaap Bastiaansen answered 5 months ago
Thanks Victor. I eventually solved it by making a separate entry (for each child) since I needed the export to have all the data (from parents and children) in the same columns.  I gave logged in users the ability to alter other users data.  When a parent is logged in they see only their children via a hidden parent ID which corresponds with another hidden child ID in order to make an unique view.  Within this view I made use of the front-end editing shortcode for only the fields that I want them to be able to change. 

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right