filter a user in a structure list
I created a small form which allows to add people to a list of events (3 fields: user, email, text).
These people can register only if they are logged into their account (so I can know who is registering and retrieve their user ID).
It works, everything is stored in a list structure, like this:
Registration-members:
-
members:
- user://YptNkRHn
email: mickael@yahoo.fr
text: TTTTTTTT
-
members:
- user://LVtYKrq4
email: test@yahoo.com
text: AAAAA
I would like to create a 2nd form to update the information.
The problem I’m having is that I’m looping through the whole thing and so I have 2 forms displayed.
I would like to display only the form of the user who is logged into his account and not all of them.
<?php
//print_r($page->registration_members()->toStructure()->findBy('user', 'user://LVtYKrq4'));die;
//print_r($page->registration_members()->toStructure()->toArray());die;
$items = $page->registration_members()->toStructure()->findBy('text', 'TTTTTTTT')->toArray();
//print_r($items); echo "dans le foreach";
foreach ($items as $item):
if ($item):
print_r($item);
endif;
endforeach
?>
I think there are 2 things I can’t do:
Go look in the structure for the “members” with its identifier (it creates an array, which I can’t reach).
Once I have retrieved the “members” of the user, I would have to be able to compare the identifier of the person connected (I suppose with kirby->user()? )
Do you have any ideas ?