$user = $site->user();
if(!$user) go('/form');
$user_name = $user->user_name();
$related_pages = page('owner')->children();
$related_page = $related_pages->filter(function($p) {
$members = $p->members()->toStructure();
$member_arr = [];
global $user_name;
foreach($members as $member) {
$member_arr[] = $member->member()->value();
}
return in_array($user_name, $member_arr);
});
This is not working because I cant pass a variable to a callback function: global $user_name is empty. Is there a more elegant way?