Update custom user field programmatically

Hi folks

I extended the user blueprint with a custom text field:

    label: Store data
    type: text

I entered some test values in the panel and successfully retrieved it with:

$user = kirby()->user($username);

Now, I would like to programmatically change the value. I tried the following but with no effect (also no error thrown):

$user->data()->value('Test XY');

I assume this is an authorization issue since no user is logged in by the time the code gets executed. So I added:

$kirby = kirby();

Still no effect. The Test XY value does not get written. Any ideas? Probably a no-brainer :wink:

Thanks & cheers


Update: just figured out the solution. To change a field, the update functions is required. This way it works:

    'data' => 'test xy'