# Create frontend user profile with filtered project overview

**URL:** <https://forum.getkirby.com/t/create-frontend-user-profile-with-filtered-project-overview/25277>\
**Category:** Questions\
**Tags:** v3\
**Created:** [April 17, 2022, 10:32am UTC](https://forum.getkirby.com/t/create-frontend-user-profile-with-filtered-project-overview/25277 "2022-04-17T10:32:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tofei](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@tofei](https://forum.getkirby.com/u/tofei)\
**Post date:** [April 17, 2022, 10:32am UTC](https://forum.getkirby.com/t/create-frontend-user-profile-with-filtered-project-overview/25277/1 "2022-04-17T10:32:14Z")

</div>

Hello Community,

I want to create a user profile page with all projects the user has organised. The page-type “project” has a user field called “organiser”.

My idea was to use the filterBy-Method to filter the projects according to the current (logged in) user and display the projects in a list with a foreach-loop.

Can you tell me what I need to change to make it work?

```auto
<?php
$user = $kirby->user();
$myprojects = page('projects')->children()->filterBy('organiser', $user);
?>
    <main class="main">
        <h1><?= $page->title() ?></h1>

        <h2> Meine Projekte </h2>
            <ul>
                <?php
                foreach($myprojects as $myproject) :?> 
                    <li>
                    <a href="<?= $myproject->url() ?>">
                        <figure>
                            <?= $myproject->image()->crop(400)?>
                            <figcaption><?= $myproject->title() ?></figcaption> 
                        </figure>  
                    </a>
                    </li>
                <?php endforeach ?>
            </ul>

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [April 17, 2022, 11:01am UTC](https://forum.getkirby.com/t/create-frontend-user-profile-with-filtered-project-overview/25277/2 "2022-04-17T11:01:32Z")

</div>

You have to convert the field value to a user object:

```auto
$user = $kirby->user();
$myprojects = page('projects')->children()->filter(fn ($child) => $child->organizer()->toUser() === $user);

```

If the `organizer` field can have multiple users:

```auto
$user = $kirby->user();
$myprojects = page('projects')->children()->filter(fn ($child) => $child->organizer()->toUsers()->has($user));

```

---

<div class="post-metadata">

**Author:** ![tofei](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@tofei](https://forum.getkirby.com/u/tofei)\
**Post date:** [April 17, 2022, 11:40am UTC](https://forum.getkirby.com/t/create-frontend-user-profile-with-filtered-project-overview/25277/3 "2022-04-17T11:40:45Z")

</div>

Thank you for the quick reply. Here’s the complete code (for anyone who wants to copy it):

```auto
<?php
$user = $kirby->user();
$myprojects = page('projekte')->children()->filter(fn ($child) => $child->organiser()->toUser() === $user);
?>
    <main class="main">
        <h1><?= $page->title() ?></h1>

        <h2> Meine Projekte </h2>

            <ul class="myprojects">
                <?php
                foreach($myprojects as $myproject) :?> 
                    <li>
                    <a href="<?= $myproject->url() ?>">
                        <figure>
                            <?= $myproject->image()->crop(400)?>
                            <figcaption><?= $myproject->title() ?></figcaption> 
                        </figure>  
                    </a>
                    </li>
                <?php endforeach ?>
            </ul>

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [April 17, 2022, 11:54am UTC](https://forum.getkirby.com/t/create-frontend-user-profile-with-filtered-project-overview/25277/4 "2022-04-17T11:54:31Z")

</div>

> [@tofei](#):
>
> ` <?= $myproject->image()->crop(400)?>`

You should make sure you really have an image, otherwise this code will throw an error if there is none:

```auto
<?php if ($image = $myproject->image()): ?>
    <figure>
        <?= $image->crop(400) ?>
        <figcaption><?= $myproject->title() ?></figcaption> 
    </figure>  
<?php endif ?>

```
