Updating user information in frontend not working

Hi!
I couldn’t find any solutions in the forum so I have to reach out.

On the website I’m building I have an ‘Edit Profile’ page where the user can update some (blueprint defined) user information. I feel like I’ve set up everything correctly but for some reason the values are not updating.

Here’s my controller:

<?php

return function ($page, $kirby, $site) {
    $user = $kirby->user();
    $error = null;
    $success = false;

    if ($kirby->request()->is('POST') && get('updateProfile')) {
        $data = [
            'country'  => get($user->country()),
            'website'  => get($user->website()),
            'shortBio' => get($user->shortBio()),
            'longBio'  => get($user->longBio())
        ];

        try {
            if ($user) {
                $user = $user->update($data);
                error_log('Update Success: User profile updated.');
                $success = true;
                go('user'); 
            } else {
                error_log('Update Error: User not found.');
                $error = 'User not found.';
            }
        } catch (Exception $e) {
            $error = $e->getMessage();
            error_log('Update Error: ' . $error);
            error_log('Exception caught: ' . $e->getMessage());
        }
    }

    return [
        'user' => $user,
        'error' => $error,
        'success' => $success
    ];
};

And the form:

<form method="post" action="<?= $page->url() ?>"> 
    <div class="form-group">
        <label for="country">Country</label>
        <input type="text" id="country" name="country" value="<?= $user->country() ?>" class="form-control">
    </div>
    <div class="form-group">
        <label for="website">Website</label>
        <input type="text" id="website" name="website" value="<?= $user->website() ?>" class="form-control">
    </div>
    <div class="form-group">
        <label for="shortBio">Short Bio</label>
        <textarea id="shortBio" name="shortBio" class="form-control"><?= $user->shortBio() ?></textarea>
    </div>
    <div class="form-group">
        <label for="longBio">Long Bio</label>
        <textarea id="longBio" name="longBio" class="form-control"><?= $user->longBio() ?></textarea>
    </div>
    <button type="submit" name="updateProfile" class="btn btn-primary">Update Profile</button>
</form>

The current information is displayed correctly on the page, but when I make changes and press ‘Update Profile’ it just resets everything.

I’ve also set the following permissions:

permissions:
  access:
    panel: false
    user: true

Thankful for any help!

Do you have a frontend login?

I do, yes.

Oh, wait, you need to fetch the form data, instead you try to use get() on user data, which doesn’t make sense.

  $data = [
            'country'  => get('country'),
           // etc.
          
        ];

Ahhh of course. Thank you Sonja!