userMethod is not called?

I created a userMethod like this:

    'userMethods' => [
        'newsletterlists' => function () {
            $lists = site()->find('newsletterlists')->childrenAndDrafts()->filterBy('recipients', '*=', $this->id());

            $page = Page::factory([
                'slug' => 'virtual',
            ]);
            foreach ($lists as $list) {
                $page->children()->add($list);
            }
            dump($page); exit;
            return $page;
        }
    ]

and i want to use that method in my user blueprint like this:

    newsletters:
        type: info
        text: "{{ user.newsletterlists }}"

It seems that the userMethod is not called at all. I tried some debugging and the function is not executed. What is my mistake?

Reference to the userMethod: https://getkirby.com/docs/reference/plugins/extensions/user-methods

You exist the method before it can return anything.

And it should be

text: "{{ kirby.user.newsletterlists }}"

The dump was just for debugging reasons, of course.

Why should it be kirby.user.something? I can call user.id and user.name and other methods as well. When i define another user method i expect it should be user.methodname, or not?

Where can you use user only apart from in a user context? In any case, it works with kirby.user and doesn’t work with user only.

Well, i’m in a user context (see initial posting: user blueprint). A user blueprint is a blueprint which defines the user profiles. In that user blueprint, you can use the query language and the $user-Object is accessible via user. For example, you can do this:

    test:
        type: info
        text: "{{ user.email }}"

This prints the users email.

After defining another user method i’d expected to be able to access it with user.methodName.

Additionally, it doesn’t work with kirby.user.methodName.

Ah, ok, I missed the context. It works without kirby in a user blueprint.

Only the standard methods seem to work, like .name, .id and so on, but my own methodName which has been defined in config.php like described in the reference doesn’t seem to be even called. The function is not executed.

You have to define custom methods in a plugin, not in the config. Where is that described that you should define custom methods in the config?

<?php

use Kirby\Cms\Page;
Kirby::plugin( 'pixelijn/custom-stuff', [
    'userMethods' => [
        'newsletterlists' => function () {
            $lists = site()->find('newsletterlists')->childrenAndDrafts()->filterBy('recipients', '*=', $this->id());

            $page = Page::factory([
                'slug' => 'virtual',
            ]);
            foreach ($lists as $list) {
                $page->children()->add($list);
            }
            return $page;
        }
    ]
] );

Yes, that is actually my mistake. It looked like it could be configured in the config, but the correct way is the plugin. Thanks!